/// <summary> /// Initializes an instance of the <see cref="UserDetailsViewModel"/> class /// </summary> public UserDetailsViewModel(UserFullDetailsDto userFullDetails) { if (userFullDetails == null) { throw new ArgumentNullException(nameof(userFullDetails)); } UserId = userFullDetails.UserId; Username = userFullDetails.Username; JobDescription = userFullDetails.JobDescription ?? throw new ArgumentNullException(nameof(userFullDetails.JobDescription)); Role = userFullDetails.Role; State = userFullDetails.State; EmployeeId = userFullDetails.EmployeeId; Title = userFullDetails.Title; Firstname = userFullDetails.Firstname; Lastname = userFullDetails.Lastname; // Gets the list of Roles for the drop down TitlesSelectListItems = SelectListHelpers.GetTitlesSelectList(Title); // Gets the list of Roles for the drop down RolesSelectListItems = SelectListHelpers.GetRolesSelectList(Role); // Gets the list of Account States for the drop down AccountStatesSelectListItems = SelectListHelpers.GetAccountStatesSelectList(State); }
private void UpdateUserProperties(ref User user, UserFullDetailsDto updatedDetails) { user.State = updatedDetails.State; user.JobDescription.Description = updatedDetails.JobDescription; user.JobDescription.Role = updatedDetails.Role; user.EmployeeDetails.Firstname = updatedDetails.Firstname; user.EmployeeDetails.Lastname = updatedDetails.Lastname; }
/// <summary> /// Initializes an instance of the <see cref="UserFullDetailsDto"/> class /// </summary> public User(UserFullDetailsDto dto) { if (dto == null) { throw new ArgumentNullException(nameof(dto)); } Id = dto.UserId; Username = dto.Username; JobDescription.Description = dto.JobDescription; JobDescription.Role = dto.Role; State = dto.State; EmployeeDetails.Id = dto.EmployeeId; EmployeeDetails.Title = dto.Title; EmployeeDetails.Firstname = dto.Firstname; EmployeeDetails.Lastname = dto.Lastname; }
/// <summary> /// Saves the updated user details /// </summary> /// <param name="userDetails"></param> /// <returns></returns> public async Task <ServiceResultStatusCode> UpdateUserDetailsAsync(UserFullDetailsDto userDetails) { if (userDetails == null) { throw new ArgumentNullException(nameof(userDetails)); } var dbUser = await _userDal.GetEntityAsync(userDetails.UserId); if (dbUser == null) { return(ServiceResultStatusCode.NotFound); } UpdateUserProperties(ref dbUser, userDetails); return(await _userDal.UpdateAsync(dbUser) != null ? ServiceResultStatusCode.Success : ServiceResultStatusCode.Failed); }