예제 #1
0
        public IdentityResult EditUser(UserManager <ApplicationUser> userManager, EditUserViewModel model)
        {
            IdentityResult result;

            var user = _adminData.GetUserByEmail(userManager, model.OldEmail);

            if (user == null)
            {
                return(new IdentityResult("User is not exist"));
            }
            if (!String.IsNullOrWhiteSpace(model.IsChangePassword) && String.IsNullOrWhiteSpace(model.NewPassword))
            {
                return(new IdentityResult("Password not entered"));
            }

            user.Email          = model.NewEmail;
            user.UserName       = model.NewEmail;
            user.FullName       = model.NewFullName;
            user.EmploymentDate = model.NewEmploymentDate;
            return(_adminData.EditUser(userManager, user
                                       , model.SelectedRoles
                                       , (String.IsNullOrWhiteSpace(model.IsChangePassword) ? model.NewPassword:null)));
        }