private bool OnApply(CalendarsModel model) { _cfg.SetDeafultCalendars( model.Calendars .Where(_ => _.IsSelected) .Select(_ => _.Name)); return(true); }
public ActionResult Calendars() { var model = new CalendarsModel { CurrentPlan = 1, Date = DateTime.UtcNow.ToString("d") }; return(View(model)); }
public ActionResult CreateActivite(int?id, int?idgroupe, bool GAC) { if (GAC) { UserCredential credential; using (var stream = new FileStream(Path.Combine(Server.MapPath("~/Credentials"), "credentials-MinFin.json"), FileMode.Open, FileAccess.Read)) { // The file token.json stores the user's access and refresh tokens, and is created // automatically when the authorization flow completes for the first time. string credPath = Path.Combine(Server.MapPath("~/Credentials"), "token" + id + ".json"); credential = GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None, new FileDataStore(credPath, true)).Result; } // Create Google Calendar API service. var service = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = ApplicationName, }); var calendars = service.CalendarList.List().Execute().Items; List <CalendarsModel> CML = new List <CalendarsModel>(); foreach (CalendarListEntry entry in calendars) { CalendarsModel CM = new CalendarsModel(); CM.ID = entry.Id; CM.Name = entry.Summary; CML.Add(CM); ViewData["colorid"] += "[" + entry.BackgroundColor + " ]<br>"; //ViewData["calendarsList"] += entry.Summary + " ID: |" + entry.Id + "|<br>"; } ViewBag.GoogleCalendarID = new SelectList(CML, "ID", "Name"); } ViewData["GAC"] = GAC; ViewBag.Type_ActiviteID = new SelectList(db.Type_Activite, "ID", "Nom_type"); ViewData["idagenda"] = id; ViewData["idgroupe"] = idgroupe; return(View()); }
public ActionResult Calendars(CalendarsModel model) { DateTime?date = null; if (model.CurrentPlan == 0) { DateTime dt; if (DateTime.TryParseExact(model.Date, "dd.MM.yyyy", null, DateTimeStyles.None, out dt)) { date = dt; } } if (model.CurrentPlan == 2) { date = DateTime.UtcNow.AddDays(-1); } ViewBag.Done = _financeHelper.UpdateCalendarsFromPlan(date); return(View()); }