public ActionResult CalendarImport(string type, string calId)
        {
            var calen = CalendarFactory.GetCalendar(new Guid(calId), (CalendarOwnerEntityEnum)Enum.Parse(typeof(CalendarOwnerEntityEnum), type));
            try
            {
                CalendarMessages(Request.Url.Query);
                if (calen == null)
                    return Redirect(Url.Content("~/calendar/" + type + "/" + calId));

                CalendarImport import = new CalendarImport();
                import.CalendarId = calen.CalendarId;
                import.GoogleCalendarUrl = calen.ImportFeedUrl;
                import.ImportType = calen.ImportFeedType;
                import.OwnerEntity = calen.OwnerEntity;
                import.TimeZones = calen.TimeZones;
                import.TimeZone = calen.TimeZone;
                import.TimeZoneId = calen.TimeZoneId;


                return View(import);
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return Redirect(Url.Content("~/calendar/" + type + "/" + calId));
        }
        public ActionResult CalendarImport(CalendarImport calendarImport)
        {

            try
            {
                var calen = CalendarFactory.UpdateCalendarFeedSettings(calendarImport);
                var import = CalendarFactory.ImportFeedFromCalendar(calendarImport.CalendarId);


                return Redirect(Url.Content("~/calendar/import/" + calendarImport.OwnerEntity + "/" + calendarImport.CalendarId.ToString().Replace("-", "") + "?u=" + SiteMessagesEnum.s));
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return Redirect(Url.Content("~/calendar/import/" + calendarImport.OwnerEntity + "/" + calendarImport.CalendarId.ToString().Replace("-", "") + "?u=" + SiteMessagesEnum.f));
        }
        public static int UpdateCalendarFeedSettings(CalendarImport import)
        {
            try
            {
                var dc = new ManagementContext();
                var cal = dc.Calendar.Where(x => x.CalendarId == import.CalendarId).FirstOrDefault();
                cal.ImportFeedUrl = import.GoogleCalendarUrl;
                cal.TimeZoneSelection = dc.TimeZone.Where(x => x.ZoneId == import.TimeZoneId).FirstOrDefault();
                if (cal.TimeZoneSelection != null)
                    cal.TimeZone = cal.TimeZoneSelection.GMTOffset;

                if (!String.IsNullOrEmpty(import.GoogleCalendarUrl))
                    cal.CalendarImportTypeEnum = (byte)CalendarImportTypeEnum.Google;
                else
                    cal.CalendarImportTypeEnum = (byte)CalendarImportTypeEnum.None;
                cal.IsCalendarInUTC = true;
                int c = dc.SaveChanges();
                return c;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return 0;
        }