示例#1
0
        protected void Application_Start()
        {
            XmlConfigurator.Configure();
            var log = LogFactory.GetLog(typeof(MvcApplication));
            log.Debug("Starting edge");

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            var rc = RouteTable.Routes;

            using (var context = new WebDataContext())
            {
                context.Database.Initialize(false);
            }

            // Registers Containing Area, such as /Admin
            AreaRegistration.RegisterAllAreas();

            // Register the stock routes plus the plugin routes
            RouteConfig.RegisterRoutes(rc);

            // Add the new View Engine for our plugins to use
            ViewEngines.Engines.Add(new PluginRazorViewEngine());

            // Register new dynamic modules/shortcodes
            DynamicModules.Instance.AddDynamicModule("responsive_image", new ResponsiveImageShortcode());
            DynamicModules.Instance.AddDynamicModule("featured_events", new EventsModule());

            Mapping.SetAutomapperMappings();
        }
 public static void EnsureRequiredSettingsExist()
 {
     using (var context = new WebDataContext())
     {
         InitSiteSettings(context);
         InitTimeZone(context);
         context.SaveChanges();
     }
 }
        public static SiteSettingsViewModel LoadSiteSettings(WebDataContext context)
        {
            var model = new SiteSettingsViewModel
            {
                Settings = context.SiteSettings.FirstOrDefault(),
                RolesList = Roles.GetAllRoles().ToList()
            };

            var configs = context.Configurations;
            foreach (var config in configs)
            {
               model.ConfigSettings.Add(config.Key, config.Value);
            }

            return model;
        }
        private static void InitTimeZone(WebDataContext context)
        {
            var timeZone = context.Configurations.FirstOrDefault();
            if (timeZone != null)
            {
                return;
            }

            var setting = new SiteConfiguration
            {
                Key = ConfigSettings.TimeZone.ToString(),
                Value = TimeZoneInfo.Utc.Id
            };

            context.Configurations.Add(setting);
        }
示例#5
0
        private static void SetLocalTimeZoneFromConfig()
        {
            try
            {
                using (var context = new WebDataContext())
                {
                    var zoneId =
                        context.Configurations.First(config => config.Key == ConfigSettings.TimeZone.ToString())
                            .Value;
                    LocalTimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(zoneId);

                    if (LocalTimeZoneInfo == null)
                    {
                        LocalTimeZoneInfo = TimeZoneInfo.Utc;
                    }
                }
            }
            catch
            {
                LocalTimeZoneInfo = TimeZoneInfo.Utc;
            }
        }
示例#6
0
 public BlogLoader(WebDataContext context = null)
 {
     _context = context ?? new WebDataContext();
     _settingsUtils = new SiteSettingsUtils(_context);
 }
 public LatestBlogsViewModel(int blogCount = 10)
 {
     Context = new WebDataContext();
     Blogs = Context.Blogs.OrderByDescending(x => x.Date).Take(blogCount).ToList();
 }
示例#8
0
 public EditContentHelper(WebDataContext context)
 {
     _context = context;
     _navigationUtils = new AdminNavigationUtils(context);
 }
示例#9
0
 public ImportTools(WebDataContext context)
 {
     _context = context;
 }
示例#10
0
 public WebUserUtils(WebDataContext context)
 {
     Context = context;
 }