public ActionResult ManageUserAccountData(UserDetailModel model) { // Validate if (ModelState.IsValid) { User user = null; int[] selectedUGIds = null; using (var proxy = new UserProxy()) { user = proxy.GetUserById(model.UserId); User userInfo = @Utilities.GetCurrentUserInfo(); if (user != null) { user = new User() { CreatedDate = user.CreatedDate, UpdatedBy = Convert.ToString(userInfo.UserName), UpdatedDate = DateTime.Now, CreatedBy = user.CreatedBy, Email = model.Email, Organisation_GUID = model.OrganizationGUID, MobileNumber = model.OfficeNumber, UserName = model.UserName, Language = model.BlastManagerWebSettingID, GUID_User = user.GUID_User, IsDeptAdmin = Convert.ToString(model.IsDeptAdmin), IsActive = Convert.ToByte(model.IsActive), UserDisplayName = user.UserDisplayName, }; model.SelectedUserGroupIdList += string.Join(";", user.UserRoles.Select(p => p.UserRoleId).ToArray()); if (!string.IsNullOrWhiteSpace(model.SelectedUserGroupIdList)) { user.UserRoles = new List <UserRole>(); selectedUGIds = model.SelectedUserGroupIdList.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Distinct().Select(p => NumericHelper.ParseInt(p).Value).ToArray(); foreach (var ugId in selectedUGIds) { user.UserRoles.Add(new UserRole() { UserRoleId = ugId }); } } proxy.UpdateUser(user); model.ShowSuccessMessage = true; model.SuccessDirectionPath = StringHelper.Format("{0}/{1}", Constants.Controllers.User, Constants.Controllers.User_UserAccount); model.SuccessMessage = Convert.ToString(Resources.Res.RES_Success); } else { return(HttpNotFound()); } } } return(View("ManageUserAccount", model)); }
public ActionResult ManageUserAccount(string id) { if (string.IsNullOrWhiteSpace(id)) { return(HttpNotFound()); } else { User user = null; string uid = id.Replace(";", "\\"); using (var proxy = new UserProxy()) { user = proxy.GetUserById(uid); } UserDetailModel model = new UserDetailModel(); if (user != null) { model.Email = user.Email; model.OrganizationGUID = user.Organisation_GUID; model.OfficeNumber = user.MobileNumber; model.UserId = user.UserName; model.IsDeptAdmin = Convert.ToBoolean(user.IsDeptAdmin); model.BlastManagerWebSettingID = user.Language; model.WindowsAccount = user.UserName; model.UserName = user.UserDisplayName; model.SelectedUserGroupIdList += string.Join(";", user.UserRoles.Select(p => p.UserRoleId).ToArray()); model.CreatedBy = Utilities.GetUserDisplayName(user.CreatedBy); model.IsActive = Convert.ToBoolean(user.IsActive); model.CreatedDate = StringHelper.ToString(user.CreatedDate, Constants.ShowDateTime); if (model.UpdatedBy != null && model.UpdatedDate != null) { model.UpdatedBy = Utilities.GetUserDisplayName(user.UpdatedBy); model.UpdatedDate = StringHelper.ToString(user.UpdatedDate, Constants.ShowDateTime); } else { model.UpdatedBy = Utilities.GetUserDisplayName(user.UpdatedBy); model.UpdatedDate = StringHelper.ToString(user.UpdatedDate, Constants.ShowDateTime); } } else { } return(View(model)); } }
public static UserInfo GetUserById(int id) { return(UserProxy.GetUserById(id)); }
public ActionResult CreateUserAccountData(UserDetailModel model) { // Validate if (ModelState.IsValid) { User user = null; UserActivity UserActivity = null; int[] selectedUGIds = null; using (var proxy = new UserProxy()) { user = proxy.GetUserById(model.UserId); if (user != null) { ModelState.AddModelError("User Id", Convert.ToString(Resources.Res.RES_Error_Unique)); } else { User userInfo = @Utilities.GetCurrentUserInfo(); user = new User() { Email = Convert.ToString(model.Email), MobileNumber = Convert.ToString(model.OfficeNumber), Password = model.Password, IsDeptAdmin = Convert.ToString(model.IsDeptAdmin), UserDisplayName = Convert.ToString(model.UserName), Organisation_GUID = model.OrganizationGUID, Language = model.BlastManagerWebSettingID, UserName = model.UserId, LastName = model.UserLastName, IsActive = Convert.ToByte(model.IsActive), CreatedBy = Convert.ToString(userInfo.UserName), CreatedDate = DateTime.Now, UpdatedBy = null, UpdatedDate = null, }; UserActivity = new UserActivity() { IsActive = Convert.ToBoolean(model.IsActive), TimeStamp = DateTime.Now, }; } if (ModelState.IsValid) { if (!string.IsNullOrWhiteSpace(model.SelectedUserGroupIdList)) { user.UserRoles = new List <UserRole>(); selectedUGIds = model.SelectedUserGroupIdList.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Distinct().Select(p => int.Parse(p)).ToArray(); foreach (var ugId in selectedUGIds) { user.UserRoles.Add(new UserRole() { UserRoleId = ugId }); } } proxy.CreateUser(user, UserActivity); model.ShowSuccessMessage = true; model.SuccessDirectionPath = string.Format("{0}/{1}", Constants.Controllers.User, Constants.Controllers.User_UserGroup); model.SuccessMessage = Convert.ToString(Resources.Res.RES_Success); } } } return(View("CreateUserAccount", model)); }