Пример #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));
        }
        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));
        }
        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));
        }
        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));
        }
        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));
        }
        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));
        }
        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));
        }