public void UpdateUser(UserUpdateInputDTO user) { IList <Withdrawal> withdrawals = sellerService.GetWithdrawalsBySellerId(user.Id); Menu menu = sellerService.GetMenuBySellerId(user.Id); this.userService.UpdateUser(new User { Id = user.Id, Email = user.Email, Name = user.Name, Password = user.Password, Rate = user.Rate, Withdrawals = withdrawals, Menu = menu }); }
public async Task <ActionResult <CommonSuccessMessageOutputDTO> > UpdateUser([FromBody] UserUpdateInputDTO userUpdateInputDTO, int userId) { try { await this.userService.UpdateUser(userUpdateInputDTO, userId); return(new CommonSuccessMessageOutputDTO() { Success = true }); } catch (Exception ex) { return(BadRequest(new { message = new List <string> { ex.Message } })); } }
/// <summary> /// Update Given User /// </summary> /// <param name="userUpdateInputDTO"></param> /// <returns></returns> public async Task UpdateUser(UserUpdateInputDTO userUpdateInputDTO, int userId) { UserEntity foundUser = await this.userRepository.GetUser(userUpdateInputDTO.UserId); bool hasAccessToUpdate = true; if (foundUser == null) { throw new ApplicationException("User not found"); } //Get the user that sent the delete request UserEntity loggedInUser = await this.userRepository.GetUser(userId); if (loggedInUser.Role == "BusinessUser") { UserAccessEntity userAccess = await this.userAccessRepository.GetUserAccess(userId); hasAccessToUpdate = userAccess != null ? userAccess.Edit : false; } if (hasAccessToUpdate) { foundUser.FirstName = userUpdateInputDTO.FirstName; foundUser.LastName = userUpdateInputDTO.LastName; foundUser.Role = userUpdateInputDTO.Role; foundUser.EmailAddress = userUpdateInputDTO.EmailAddress; foundUser.EmailVerified = userUpdateInputDTO.EmailVerified; foundUser.MaxUsers = userUpdateInputDTO.MaxUsers; await this.userRepository.UpdateUser(foundUser); } else { throw new UnauthorizedAccessException("User don't have access to perform Edit operation"); } }
public void UpdateUser(UserUpdateInputDTO user) { this.userAppService.UpdateUser(user); }