public ActionResult SyncToGoogleCalendar()
 {
     if (string.IsNullOrWhiteSpace(GoogleOauthTokenService.OauthToken))
     {
         var redirectUri = GoogleCalendarSyncer.GetOauthTokenUri(this);
         return(Redirect(redirectUri));
     }
     else
     {
         var success = GoogleCalendarSyncer.SyncToGoogleCalendar(this);
         if (!success)
         {
             return(Json("Token was revoked. Try again."));
         }
     }
     return(Redirect("~/"));
 }
 public ActionResult AddEvent(GoogleEventInfo info)
 {
     if (string.IsNullOrWhiteSpace(GoogleOauthTokenService.OauthToken))
     {
         var redirectUri = GoogleCalendarSyncer.GetOauthTokenUri(this);
         return(Redirect(redirectUri));
     }
     else
     {
         var success = GoogleCalendarSyncer.AddToGoogleCalendar(this, info);
         if (!success)
         {
             return(RedirectToAction("_SyncToGoogleCalendarError"));
             //return Json("Token was revoked. Try again.");
         }
     }
     return(RedirectToAction("GetEvents"));
 }
Exemplo n.º 3
0
        public ActionResult SyncToGoogleCalendar()
        {
            GoogleOauthTokenService.OauthToken = "";
            if (string.IsNullOrWhiteSpace(GoogleOauthTokenService.OauthToken))
            {
                var redirectUri = GoogleCalendarSyncer.GetOauthTokenUri(this);
                return(Redirect(redirectUri));
            }

            /*else
             * {
             *  var success = GoogleCalendarSyncer.SyncToGoogleCalendar(this);
             *  if (!success)
             *  {
             *      return Json("Token was revoked. Try again.",JsonRequestBehavior.AllowGet);
             *  }
             * }*/
            return(new RedirectResult("~/Home/Login"));
        }