public IEnumerable <TeamListModel> GetAll() { using (var dbContext = dbContextFactory.CreateDbContext()) { return(dbContext.Teams.Select(e => TeamMapper.EntityToListModel(e))); } }
public List <TeamListModel> GetAll() { using (var dbContext = dbContextFactory.CreateDbContext()) { var teamMapper = new TeamMapper(); return(dbContext.Teams.Include("Members").Select(e => teamMapper.EntityToListModel(e)).ToList()); } }
public void EntityToListModel_ShouldBeEqual() { var model = new Team() { Id = Guid.NewGuid(), Name = "Film stars", }; var returned = TeamMapper.EntityToListModel(model); Assert.Equal(model.Id, returned.Id); Assert.Equal(model.Name, returned.Name); Assert.IsType <TeamListModel>(returned); }