private static void GetAUser() { Console.Write("Please enter the User ID: "); int id = int.Parse(Console.ReadLine()); IUserDTO retrievedUserDTO = FactoryBase.CreateDTOInstance <IUserDTO>(); retrievedUserDTO = userBDC.GetAUser(id); PrintJSONifyUserDTO(retrievedUserDTO); }
public IUserDTO GetAUser(int id) { IUserDTO userDTO = FactoryBase.CreateDTOInstance <IUserDTO>(); using (UserStoryEntities context = new UserStoryEntities()) { User user = context.Users.Find(id); EntityConverter.FillDTOFromEntity(userDTO, user); } return(userDTO); }
public List <IUserDTO> GetAllUsers() { List <IUserDTO> usersDTO = new List <IUserDTO>(); UserStoryEntities context = new UserStoryEntities(); using (context) { foreach (User user in context.Users) { IUserDTO userDTO = FactoryBase.CreateDTOInstance <IUserDTO>(); EntityConverter.FillDTOFromEntity(userDTO, user); usersDTO.Add(userDTO); } } return(usersDTO); }