示例#1
0
        public virtual ActionResult Index(string calendarId, int year, int month)
        {
            try
            {
                var calendarService = this.GetAgendaService();
                var importer        = new AgendaImporter(calendarService);
                var events          = importer.GetEventsModel(calendarId);

                var locationOptimizer = new LocationOptimizer();
                events = locationOptimizer.OptimizeLocations(events);

                var start = new DateTime(year, month, 1);
                var end   = start.AddMonths(1);
                var eventsOfSelectedMonth = events.Where(e => e.Start >= start && e.End <= end);

                var routes = routeCalculator.CalculateRoutes(eventsOfSelectedMonth, "Van koetsveldstraat 39, Utrecht");
                var model  = routeCalculator.CalculateTravelCosts(routes);

                return(View(model));
            }
            catch (NoAuthenticatorException)
            {
                return(RedirectToRoute("GoogleAuthentication", new { callbackurl = Request.Url }));
            }
        }
示例#2
0
 public virtual ActionResult ShowEvents(string calendarId)
 {
     try
     {
         var calendarService = this.GetAgendaService();
         var importer        = new AgendaImporter(calendarService);
         var model           = importer.GetEventsModel(calendarId);
         Session["eventModel"] = model;
         return(View(model));
     }
     catch (NoAuthenticatorException)
     {
         return(RedirectToRoute("GoogleAuthentication", new { callbackurl = Request.Url }));
     }
 }