dfmmalaw
4/3/2017 - 4:21 PM

Created a new model property (but not in DB) and displayed it client-side.

Created a new model property (but not in DB) and displayed it client-side.

<div class="form-group">
    <label class="label-col col-xs-4 control-label" for="PasswordExpiration">Password Expiration</label>
    <div class="col-xs-8 dateSpan">
        <span id="PasswordExpiration" name="PasswordExpiration">@(Model.ExpirationDate)</span>
    </div>
</div>
public string ExpirationDate { get; set; }
public ActionResult editView(long clientUserId)
{
    ClientUser clientUser = clientUserRepository.findById(clientUserId);
    MembershipUser membershipUser = clientMembershipProvider.retrieveUser(clientUser.User.UserName);
    //defined it here and set it below while setting it to a string
    DateTime expirationDate = membershipUser.LastPasswordChangedDate.AddDays(90);

    ViewBag.MenuTab = MenuTabs.ADMIN_CLIENTS;
    ViewBag.SubMenu = MenuTabs.ADMIN_CLIENT_USER_CONTRACTS;
    ViewBag.ClientId = clientUser.ClientId;
    ViewBag.Title = "Client User";
    ViewBag.ClientAccount = clientUser.Client.AccountName;

    CuEdit model = new CuEdit();
    model.IsApiEnabled = clientConfigurationRepository.isApiEnabled(clientUser.ClientId);
    model.AvailableSalutations = enumLookupRepository.findAllSalutations();
    model.AvailableStates = stateRepository.findAllSelectListItem();
    model.ClientUserId = clientUserId;
    model.ClientId = clientUser.ClientId;
    model.HasEditRole = MembershipHelper.verifyRoles(webRequestState.UserName, StaffRoles.OrClientEdit,staffRoleProvider);
    model.IsEnabled = clientUser.IsEnabled;
    model.UserName = clientUser.User.UserName;
    model.EmailAddress = clientUser.EmailAddress;
    model.Title = clientUser.Title;
    model.Salutation = clientUser.Salutation;
    model.FirstName = clientUser.FirstName;
    model.LastName = clientUser.LastName;
    model.Status = membershipUser.IsApproved;
    model.PhoneNumber = clientUser.PhoneNumber;
    model.Extension = clientUser.Extension;
    model.AddressLine1 = clientUser.AddressLine1;
    model.AddressLine2 = clientUser.AddressLine2;
    model.City = clientUser.City;
    model.State = clientUser.State;
    model.ZipCode = clientUser.ZipCode;
    model.ChangePassword = clientUser.ChangePassword;
    model.Roles = clientRoleProvider.GetRolesForUser(clientUser.User.UserName);
    model.AvailableRoles = ClientRoles.AllRoles;
    model.SmsPhone = clientUser.SmsPhone;
    model.FacebookLink = clientUser.FacebookLink;
    model.TwitterLink = clientUser.TwitterLink;
    model.SterlingWestUserName = clientUser.SterlingWestUserName;
    model.TwitterPassword = clientUser.TwitterPassword;
    model.FacebookPassword = clientUser.FacebookPassword;
    // had to set it to a string and use "d" as the formatting type
    model.ExpirationDate = expirationDate.ToString("d");

    return View(model);
}