public UserDTO(UserDTO user) { UserId = user.UserId; Login = user.Login; FirstName = user.FirstName; LastName = user.LastName; Email = user.Email; }
public ListResponse<UserDTO> GetAllUsers() { using (var context = new AF_Context()) { try { List<UserDTO> tmp = new List<UserDTO>(); foreach (User a in (from u in context.Users select u)) { var newUserDto = new UserDTO() { UserId = a.UserId, Login = a.Login, FirstName = a.FirstName, LastName = a.LastName, Email = a.Email }; tmp.Add(newUserDto); } return (new ListResponse<UserDTO>(tmp)); } catch (Exception ex) { throw; } } }
public SingleItemResponse<UserDTO> GetUser(int id) { using (var context = new AF_Context()) { try { User us = context.Users.First(u => u.UserId == id); var newUserDto = new UserDTO() { UserId = us.UserId, Login = us.Login, FirstName = us.FirstName, LastName = us.LastName, Email = us.Email }; return (new SingleItemResponse<UserDTO>(newUserDto)); } catch (Exception ex) { throw; } } }