public Model Handle(Query message) { var upcomingExhibits = _repository.GetUpcomingExhibits(message.SearchTerm); var attendances = _attendanceRepository.GetAllAttendances(); var model = new Model { UpcomingExhibits = upcomingExhibits.Select(ue => new Model.Exhibit { Id = ue.Id, PhotographerId = ue.PhotographerId, Location = ue.Location, ImageUrl = _urlComposer.ComposeImgUrl(ue.ImageUrl), DateTime = ue.DateTime, IsCanceled = ue.IsCanceled, Genre = new Model.Exhibit.GenreT { Name = ue.Genre.Name } }).ToList(), Attendances = attendances.Select(a => new Model.Attendance { ExhibitId = a.ExhibitId, AttendeeId = a.AttendeeId }).ToList(), ShowActions = message.ShowActions, UserId = message.UserId, Heading = "SEARCH RESULTS" }; return(model); }
public Model Handle(Query message) { var upcomingExhibits = _exhibitRepository.GetUpcomingExhibits(message.SearchTerm); var attendances = _attendanceRepository.GetAllAttendances(); var model = new Model { Attendances = attendances.Select(a => new Model.Attendance { ExhibitId = a.ExhibitId, AttendeeId = a.AttendeeId }).ToList(), ShowActions = message.ShowActions, UserId = message.UserId, PhotographerId = message.PhotographerId, Heading = "NYC Photography Exhibits" }; int pageSize = 8; int pageNumber = (message.Page ?? 1); model.UpcomingExhibits = upcomingExhibits.Select(ue => new Model.Exhibit { Id = ue.Id, PhotographerId = ue.PhotographerId, Location = ue.Location, ImageUrl = _urlComposer.ComposeImgUrl(ue.ImageUrl), DateTime = ue.DateTime, IsCanceled = ue.IsCanceled, Genre = new Model.Exhibit.GenreT { Name = ue.Genre.Name }, Photographer = new Model.Exhibit.PhotographerT { Name = ue.Photographer.Name } }).ToList().ToPagedList(pageNumber, pageSize); // isToList necessary? return(model); }