コード例 #1
0
        public ActionResult Update(Models.Event editEvent)
        {
            if (editEvent.Start > editEvent.End)
            {
                ModelState.AddModelError("End", "End time cannot be before start time");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    CronofyHelper.UpsertEvent(editEvent.EventId, editEvent.CalendarId, editEvent.Summary, editEvent.Description, editEvent.Start, editEvent.End, new Cronofy.Location(editEvent.LocationDescription, editEvent.Latitude, editEvent.Longitude));
                }
                catch (CronofyResponseException ex)
                {
                    editEvent.SetError(ex);
                }

                if (editEvent.NoErrors())
                {
                    return(new RedirectResult(String.Format("/calendars/show/{0}", editEvent.CalendarId)));
                }
            }

            editEvent.Calendar = CronofyHelper.GetCalendars().First(x => x.CalendarId == editEvent.CalendarId);

            return(View("Edit", editEvent));
        }
コード例 #2
0
        public ActionResult Create(Models.Channel channel)
        {
            if (ModelState.IsValid)
            {
                var url = ConfigurationManager.AppSettings["domain"] + "/push/channel/" + channel.Path;

                try
                {
                    CronofyHelper.CreateChannel(url, channel.OnlyManaged, channel.CalendarIds);
                }
                catch (CronofyResponseException ex)
                {
                    channel.SetError(ex);
                }

                if (channel.NoErrors())
                {
                    return(new RedirectResult("/channels"));
                }
            }

            ViewData["domain"]    = ConfigurationManager.AppSettings["domain"];
            ViewData["calendars"] = CronofyHelper.GetCalendars();

            return(View("New", channel));
        }
コード例 #3
0
        public ActionResult CreateEvent(Models.Event newEvent)
        {
            ImpersonateUser(newEvent.UserId);

            if (newEvent.Start > newEvent.End)
            {
                ModelState.AddModelError("End", "End time cannot be before start time");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    CronofyHelper.UpsertEvent(newEvent.EventId, newEvent.CalendarId, newEvent.Summary, newEvent.Description, newEvent.Start, newEvent.End);
                }
                catch (CronofyResponseException ex)
                {
                    newEvent.SetError(ex);
                }

                if (newEvent.NoErrors())
                {
                    return(new RedirectResult(String.Format("/serviceaccountusers/show/{0}/calendar/{1}", newEvent.UserId, newEvent.CalendarId)));
                }
            }

            ViewData["calendarName"] = CronofyHelper.GetCalendars().First(x => x.CalendarId == newEvent.CalendarId).Name;

            return(View("NewEvent", newEvent));
        }
コード例 #4
0
        public ActionResult Show(string id)
        {
            var calendar = CronofyHelper.GetCalendars().First(x => x.CalendarId == id);

            ViewData["events"] = CronofyHelper.ReadEventsForCalendar(id);

            return(View("Show", calendar));
        }
コード例 #5
0
        public ActionResult Show(string id)
        {
            var shownEvent = CronofyHelper.ReadEvents().First(x => x.EventUid == id);

            ViewData["calendarName"] = CronofyHelper.GetCalendars().First(x => x.CalendarId == shownEvent.CalendarId).Name;
            ViewData["google_maps_embed_api_key"] = ConfigurationManager.AppSettings["google_maps_embed_api_key"];

            return(View("Show", shownEvent));
        }
コード例 #6
0
        public ActionResult Index()
        {
            var calendars = CronofyHelper.GetCalendars();
            var freeBusy  = CronofyHelper.GetFreeBusy();

            var model = freeBusy
                        .GroupBy(x => x.CalendarId)
                        .ToDictionary(x => calendars.First(cal => cal.CalendarId == x.Key), x => x.ToList());

            return(View("Index", model));
        }
コード例 #7
0
        public ActionResult Calendar(string userId, string calendarId)
        {
            ImpersonateUser(userId);

            var calendar = CronofyHelper.GetCalendars().First(x => x.CalendarId == calendarId);

            ViewData["userId"] = userId;
            ViewData["events"] = CronofyHelper.ReadEventsForCalendar(calendarId);

            return(View("Calendar", calendar));
        }
コード例 #8
0
        public ActionResult Index()
        {
            var profiles  = new Dictionary <Cronofy.Profile, Cronofy.Calendar[]>();
            var calendars = CronofyHelper.GetCalendars();

            foreach (var profile in CronofyHelper.GetProfiles())
            {
                profiles.Add(profile, calendars.Where(x => x.Profile.ProfileId == profile.Id).ToArray());
            }

            return(View(profiles));
        }
コード例 #9
0
        public ActionResult New([Bind(Prefix = "id")] string calendarId)
        {
            var newEvent = new Models.Event
            {
                Calendar   = CronofyHelper.GetCalendars().First(x => x.CalendarId == calendarId),
                CalendarId = calendarId,

                EventId = "unique_event_id_" + (new Random().Next(0, 1000000).ToString("D6"))
            };

            return(View("New", newEvent));
        }
コード例 #10
0
        public ActionResult New()
        {
            var calendars = CronofyHelper.GetCalendars();

            var channel = new Models.Channel
            {
                CalendarIds = calendars.Select(x => x.CalendarId).ToArray(),
            };

            ViewData["domain"]    = ConfigurationManager.AppSettings["domain"];
            ViewData["calendars"] = calendars;

            return(View("New", channel));
        }
コード例 #11
0
        public ActionResult NewEvent(string userId, string calendarId)
        {
            ImpersonateUser(userId);

            ViewData["calendarName"] = CronofyHelper.GetCalendars().First(x => x.CalendarId == calendarId).Name;

            var newEvent = new Models.Event
            {
                UserId     = userId,
                CalendarId = calendarId,
                EventId    = "unique_event_id_" + (new Random().Next(0, 1000000).ToString("D6"))
            };

            return(View("NewEvent", newEvent));
        }
コード例 #12
0
        public ActionResult Edit(string id)
        {
            var gotEvent = CronofyHelper.ReadEvents().First(x => x.EventUid == id);

            var editEvent = new Models.Event
            {
                Calendar   = CronofyHelper.GetCalendars().First(x => x.CalendarId == gotEvent.CalendarId),
                CalendarId = gotEvent.CalendarId,

                EventId             = gotEvent.EventId,
                Summary             = gotEvent.Summary,
                Description         = gotEvent.Description,
                Start               = (gotEvent.Start.HasTime ? gotEvent.Start.DateTimeOffset.DateTime : gotEvent.Start.Date.DateTime),
                End                 = (gotEvent.End.HasTime ? gotEvent.End.DateTimeOffset.DateTime : gotEvent.End.Date.DateTime),
                LocationDescription = gotEvent.Location == null ? null : gotEvent.Location.Description,
                Latitude            = gotEvent.Location == null ? null : gotEvent.Location.Latitude,
                Longitude           = gotEvent.Location == null ? null : gotEvent.Location.Longitude
            };

            return(View("Edit", editEvent));
        }
コード例 #13
0
        public ActionResult Show([Bind(Prefix = "id")] string userId)
        {
            var enterpriseConnectData = DatabaseHandler.Get <EnterpriseConnectUserData>("SELECT CronofyUID, Email, Status FROM EnterpriseConnectUserData WHERE CronofyUID=@userId AND OwnedBy=@uidCookie",
                                                                                        new Dictionary <string, object> {
                { "userId", userId }, { "uidCookie", uidCookie.Value }
            });

            ImpersonateUser(userId);

            var profiles  = new Dictionary <Cronofy.Profile, Cronofy.Calendar[]>();
            var calendars = CronofyHelper.GetCalendars();

            foreach (var profile in CronofyHelper.GetProfiles())
            {
                profiles.Add(profile, calendars.Where(x => x.Profile.ProfileId == profile.Id).ToArray());
            }

            ViewData["profiles"] = profiles;

            return(View("Show", enterpriseConnectData));
        }