public async Task <int> AddUser(UserDTO userDTO) { try { User user = MapperUser.MapFromDToEntitiy(userDTO); _userService.Add(user); int result = await _uwo.CommitChanges(); List <User> lstUser = await _userService.GetAllUsers().ToListAsync(); return(result > 0 ? lstUser.OrderBy(u => u.Id).Last().Id : 0); } catch (Exception ex) { throw new Exception("User.AddUser", ex); } }
public async Task <UserDTO> UpdateUser(UserDTO userDTO) { try { User user = MapperUser.MapFromDToEntitiy(userDTO); _userService.Update(user); await _uwo.CommitChanges(); List <User> lstUser = await _userService.GetAllUsers().ToListAsync(); user = lstUser.FirstOrDefault(u => u.Id.Equals(userDTO.UserId)); return(MapperUser.MapFromEntitiyToDTO(new List <User>() { user }).FirstOrDefault()); } catch (Exception ex) { throw new Exception("User.UpdateUser", ex); } }