public ActionResult CheckEvents()
        {
            try
            {
                repository.ClearAppointments();
                var start = Convert.ToDateTime(Request["start"]);
                var end   = Convert.ToDateTime(Request["end"]);

                var appointmentIds = service.CheckRange(start, end);

                foreach (string id in appointmentIds)
                {
                    Appointment app = service.GetAppointment(id);
                    repository.SaveAppointment(app);
                }

                return(View("Appointment", repository.Appointments));
            }
            catch (Exception e)
            {
                if (e.Message == "Caller needs to authenticate.")
                {
                    return(new EmptyResult());
                }
                return(RedirectToAction("Index", "Error", new { message = Request.RawUrl + ": " + e.Message }));
            }
        }
 public void SignIn()
 {
     if (!Request.IsAuthenticated)
     {
         repository.ClearAppointments();
         // Signal OWIN to send an authorization request to Azure.
         HttpContext.GetOwinContext().Authentication.Challenge(
             new AuthenticationProperties {
             RedirectUri = "/"
         },
             OpenIdConnectAuthenticationDefaults.AuthenticationType);
     }
 }