// because i didn't want to inject other services in the view public HomeLoggedModel GetHomeViewDetails() { var homeViewModel = new HomeLoggedModel { Stories = this.Context.FictionStories .Include(x => x.Ratings) .Include(x => x.Author) .OrderByDescending(x => x.CreatedOn) .Take(2).ProjectTo <StoryHomeOutputModel>(Mapper.ConfigurationProvider).ToList(), Announcements = this.Context.Announcements .Where(x => x.PublshedOn.AddMonths(1) >= DateTime.Now.Date) .OrderByDescending(x => x.PublshedOn) .Take(3) .ProjectTo <AnnouncementOutputModel>(Mapper.ConfigurationProvider) .ToList() }; return(homeViewModel); }
public HomeLoggedModel GetHomeViewDetails() { var model = new HomeLoggedModel() { LatestBooks = this.Context.Books .Include(x => x.Chapters) .Include(x => x.Author) .OrderByDescending(x => x.CreatedOn) .Take(2) .ProjectTo <BookHomeOutputModel>(Mapper.ConfigurationProvider) .ToList(), LatestAnnouncements = this.Context.Announcements .Include(x => x.Author) .OrderByDescending(x => x.PublishedOn) .Take(2) .ProjectTo <AnnouncementOutputModel>(Mapper.ConfigurationProvider) .ToList() }; return(model); }