public ActionResult EditUser(String userName) { MembershipUser user = Membership.GetUser(userName, true); UserEditModel userEditModel = new UserEditModel(); userEditModel.UserName = user.UserName; userEditModel.LastPasswordChangedDate = user.LastPasswordChangedDate; userEditModel.LastLoginDate = user.LastLoginDate; userEditModel.IsLockedOut = user.IsLockedOut; userEditModel.LastLockoutDate = user.LastLockoutDate; userEditModel.IsApproved = user.IsApproved; userEditModel.Email = user.Email; userEditModel.CreationDate = user.CreationDate; userEditModel.GetRolesForUser = Roles.GetRolesForUser(userName); userEditModel.Comment = user.Comment; AuthenticationsAndAuthorizationsOperations anaOPs = new AuthenticationsAndAuthorizationsOperations(); userEditModel.ExpiredDate = anaOPs.GetExpiryDate(userName); userEditModel.PhonePIN = anaOPs.getMobilPINByUserName(userName); DocumentsOperations documentsOperations = new DocumentsOperations(); userEditModel.PhoneAlias = anaOPs.GetMobileAliasByUserName(userName); return(View(userEditModel)); }
public static DateTime GetExpiryDate() { string userName = System.Web.Security.Membership.GetUser().UserName; AuthenticationsAndAuthorizationsOperations AuthenticationsAndAuthorizationsOperations = new AuthenticationsAndAuthorizationsOperations(); DateTime expirydate = AuthenticationsAndAuthorizationsOperations.GetExpiryDate(userName); return expirydate; }
public JsonResult GetUsersRoleJson(String roleName) { AuthenticationsAndAuthorizationsOperations anaOps = new AuthenticationsAndAuthorizationsOperations(); List <ListUsersViewModel> usersInRoleList = new List <ListUsersViewModel>(); List <ListUsersViewModel> usersNOTInRoleList = new List <ListUsersViewModel>(); if (!String.IsNullOrEmpty(roleName) && Roles.RoleExists(roleName)) { String[] inRoleUsers = Roles.GetUsersInRole(roleName); MembershipUserCollection allUsers = Membership.GetAllUsers(); foreach (MembershipUser user in allUsers) { ListUsersViewModel listUsersViewModel = new ListUsersViewModel(); if (inRoleUsers.Contains(user.UserName)) { listUsersViewModel.Email = user.Email; listUsersViewModel.ExpiredDate = (anaOps.GetExpiryDate(user.UserName)).ToString(dateTimeFormat); listUsersViewModel.LastActivityDate = (user.LastActivityDate).ToString(dateTimeFormat); listUsersViewModel.MobileAlias = anaOps.GetMobileAliasByUserName(user.UserName); listUsersViewModel.UserName = user.UserName; listUsersViewModel.ThisRoleOwner = anaOps.IsRoleOwner(user.UserName, roleName); usersInRoleList.Add(listUsersViewModel); } if (!inRoleUsers.Contains(user.UserName)) { listUsersViewModel.Email = user.Email; listUsersViewModel.ExpiredDate = (anaOps.GetExpiryDate(user.UserName)).ToString(dateTimeFormat); listUsersViewModel.LastActivityDate = (user.LastActivityDate).ToString(dateTimeFormat); listUsersViewModel.MobileAlias = anaOps.GetMobileAliasByUserName(user.UserName); listUsersViewModel.UserName = user.UserName; usersNOTInRoleList.Add(listUsersViewModel); } } } return(Json(new { TotalInRole = usersInRoleList.Count, DataInRole = usersInRoleList, TotalNotInRole = usersNOTInRoleList.Count, DataNotInRole = usersNOTInRoleList })); }
public JsonResult ListUsers(String userName) { MembershipUserCollection users = Membership.GetAllUsers(); List <ListUsersViewModel> listRoles = new List <ListUsersViewModel>(); AuthenticationsAndAuthorizationsOperations aNaOps = new AuthenticationsAndAuthorizationsOperations(); DocumentsOperations documentsOperations = new DocumentsOperations(); foreach (MembershipUser user in users) { listRoles.Add(new ListUsersViewModel { UserName = user.UserName, MobileAlias = aNaOps.GetMobileAliasByUserName(user.UserName), Email = user.Email, LastActivityDate = (user.LastActivityDate).ToString(dateTimeFormat), ExpiredDate = (aNaOps.GetExpiryDate(user.UserName)).ToString(dateTimeFormat) }); } return(Json(new { Total = listRoles.Count, Data = listRoles })); }