Ejemplo n.º 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 }));
            }
        }
Ejemplo n.º 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 }));
     }
 }
Ejemplo n.º 3
0
 public virtual ActionResult SelectCalendar()
 {
     try
     {
         var calendarService = this.GetAgendaService();
         var importer        = new AgendaImporter(calendarService);
         var model           = importer.GetCalendarsModel();
         if (model.Count() == 1)
         {
             // only one agenda, so select it by default and move on the other
         }
         return(View(model));
     }
     catch (NoAuthenticatorException)
     {
         return(RedirectToRoute("GoogleAuthentication", new { callbackurl = Request.Url }));
     }
 }