public ShowListItem GetTopShow() { using (var ctx = new ApplicationDbContext()) { var shows = ctx.Shows; if (shows.Count() == 0) { return(null); } var orderedShows = shows.OrderByDescending(m => m.AnticipationValue); Show show = orderedShows.First(); ShowListItem showItem = new ShowListItem() { Id = show.Id, PosterUrl = show.PosterUrl, Title = show.Title, Description = show.Description, Franchise = show.Franchise, PremierDate = show.PremierDate, }; return(showItem); } }
public IEnumerable <ShowListItem> GetShows() { using (var ctx = new ApplicationDbContext()) { var query = ctx.Shows .ToList(); List <ShowListItem> Result = new List <ShowListItem>(); foreach (Show e in query) { ShowListItem show = new ShowListItem { ID = e.ID, Name = e.Name, AverageScore = e.AverageScore }; Result.Add(show); } return(Result); } }