public async Task <IEnumerable <UserDTO> > GetAllUsers() { try { List <User> users = await _userService.GetAllUsers().ToListAsync(); return(MapperUser.MapFromEntitiyToDTO(users)); } catch (Exception ex) { throw new Exception("User.GetAllUsers", ex); } }
public async Task <UserDTO> GetById(int id) { try { List <User> lstUser = await _userService.GetAllUsers().ToListAsync(); User user = lstUser.FirstOrDefault(u => u.Id.Equals(id)); return(MapperUser.MapFromEntitiyToDTO(new List <User>() { user }).FirstOrDefault()); } catch (Exception ex) { throw new Exception("User.GetById", 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); } }