public ActionResult New([Bind(Prefix = "id")] string profileId)
        {
            ViewData["profileName"] = CronofyHelper.GetProfiles().First(x => x.Id == profileId).Name;

            var calendar = new Models.Calendar
            {
                ProfileId = profileId,
            };

            return(View("New", 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));
        }
        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));
        }
        public ActionResult Create(Models.Calendar calendar)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    CronofyHelper.CreateCalendar(calendar.ProfileId, calendar.Name);
                }
                catch (CronofyResponseException ex)
                {
                    calendar.SetError(ex);
                }

                if (calendar.NoErrors())
                {
                    return(new RedirectResult("/profiles"));
                }
            }

            ViewData["profileName"] = CronofyHelper.GetProfiles().First(x => x.Id == calendar.ProfileId).Name;

            return(View("New", calendar));
        }