public ActionResult Index(string location, string keyword, string fromDate, string toDate) { List<EventViewModel> events; //Local events search events = LocalEventSearch(location, keyword); //Local date search events = LocalEventsDateSearch(fromDate, toDate, events); //Local events sorting var upcomingEvents = events.Where(e => e.StartDateTime > DateTime.Now).ToList(); var passedEvents = events.Where(e => e.StartDateTime <= DateTime.Now).ToList(); var result = (new UpcomingPassedEventsViewModel() { UpcomingEvents = upcomingEvents, PassedEvents = passedEvents }); //Getting results from Eventful EventfulSearch api = new EventfulSearch(); if (!string.IsNullOrEmpty(keyword)) api.Keyword = keyword; if (!string.IsNullOrEmpty(location)) api.Location = location; api.Date = FormatEventfulSearchDateRange(fromDate, toDate); var eventfulEvents = api.Search().ConvertToEventViewModel(); //Add the Eventful Events to the database events and resort var temp = eventfulEvents.Where(e => e.StartDateTime > DateTime.Now).OrderBy(m => m.StartDateTime).AddMissingImagesToTheirEvents(); result.UpcomingEvents = result.UpcomingEvents.Concat(temp).ToList(); var temp1 = eventfulEvents.Where(e => e.StartDateTime <= DateTime.Now).OrderBy(m => m.StartDateTime).AddMissingImagesToTheirEvents(); result.PassedEvents = result.PassedEvents.Concat(temp1).ToList(); return View(result); }
public ActionResult Index() { var events = this.eventsdb.Events .Where(e => e.IsPublic) .OrderBy(e => e.StartDateTime); var eventViews = EventsController.AddImagesToOurEvents(events); var upcomingEvents = eventViews.Where(e => e.StartDateTime > DateTime.Now).ToList(); var passedEvents = eventViews.Where(e => e.StartDateTime <= DateTime.Now).ToList(); var result = (new UpcomingPassedEventsViewModel() { UpcomingEvents = upcomingEvents, PassedEvents = passedEvents }); //Getting results from Eventful EventfulSearch api = new EventfulSearch(); api.Location = "Atlanta"; api.Date = DateTime.Now.AddDays(1).ToString("yyyyMMdd") + "00-" + DateTime.Now.AddDays(15).ToString("yyyyMMdd") + "00"; var eventfulEvents = api.Search().ConvertToEventViewModel(); //Add the Eventful Events to the database events and resort var temp = eventfulEvents.Where(e => e.StartDateTime > DateTime.Now).OrderBy(m => m.StartDateTime).AddMissingImagesToTheirEvents(); result.UpcomingEvents = result.UpcomingEvents.Concat(temp).ToList(); var temp1 = eventfulEvents.Where(e => e.StartDateTime <= DateTime.Now).OrderBy(m => m.StartDateTime).AddMissingImagesToTheirEvents(); result.PassedEvents = result.PassedEvents.Concat(temp1).ToList(); return View(result); }
public ActionResult Index() { var events = this.eventsdb.Events .OrderBy(e => e.StartDateTime) .Where(e => e.IsPublic) .Select(EventViewModel.ViewModel); var upcomingEvents = events.Where(e => e.StartDateTime > DateTime.Now).ToList(); var passedEvents = events.Where(e => e.StartDateTime <= DateTime.Now).ToList(); var result = (new UpcomingPassedEventsViewModel() { UpcomingEvents = upcomingEvents, PassedEvents = passedEvents }); //Getting results from Eventful EventfulSearch api = new EventfulSearch(); api.Location = "Atlanta"; api.Date = DateTime.Now.ToString("MMMM"); var eventfulEvents = api.Search().ConvertToEventViewModel(); //Add the Eventful Events to the database events and resort result.UpcomingEvents = result.UpcomingEvents.Concat(eventfulEvents.Where(e => e.StartDateTime > DateTime.Now)).OrderBy(m => m.StartDateTime); result.PassedEvents = result.PassedEvents.Concat(eventfulEvents.Where(e => e.StartDateTime <= DateTime.Now)).OrderBy(m => m.StartDateTime); return View(result); }