public UserViewModel(INventoryUser user) { Id = user.Id; UserName = user.UserName; Email = user.Email; Name = user.Name; Surname = user.Surname; Patronymic = user.Patronymic; StaffNumber = user.StaffNumber; Roles = user.Roles; }
public async Task <Result> UpdateUserAsync(INventoryUser user, IList <string> selectedRoles = null) { var identityUser = await _userManager.Users.FirstOrDefaultAsync(x => x.Id == user.Id); identityUser.Name = user.Name; identityUser.Surname = user.Surname; identityUser.Patronymic = user.Patronymic; identityUser.StaffNumber = user.StaffNumber; identityUser.Email = user.Email; var result = await _userManager.UpdateAsync(identityUser); if (selectedRoles != null) { await UpdateRoles(user.Id, selectedRoles); } return(new Result(result.Succeeded)); }
public async Task <Result> CreateUserAsync(INventoryUser user, string password) { if (user == null) { throw new ArgumentNullException(nameof(user)); } var newUser = new NventoryUser() { Id = user.Id, UserName = user.UserName, Email = user.Email, Name = user.Name, Surname = user.Surname, Patronymic = user.Patronymic, StaffNumber = user.StaffNumber }; var result = await _userManager.CreateAsync(newUser, password).ConfigureAwait(false); return(new Result(result.Succeeded, result.Errors.Select(e => e.Description).ToArray())); }