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(); SettingsInitializer.EnsureRequiredSettingsExist(); }
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); }
public override int SaveChanges(System.Data.Objects.SaveOptions options) { var modified = this.ObjectStateManager.GetObjectStateEntries(EntityState.Modified | EntityState.Added); // Get the list of things to update var result = base.SaveChanges(options); // Call the base SaveChanges, which clears that list. using (var context = new WebDataContext()) // This is the second database context. { foreach (var obj in modified) { var table = obj.Entity as IAdvantageWebTable; if (table != null) { table.UpdateWeb(context); // This is IAdvantageWebTable.UpdateWeb(), which calls all the existing logic I've had in place for years. } } context.SubmitChanges(); } return(result); }
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; } }
public BlogLoader(WebDataContext context = null) { _context = context ?? new WebDataContext(); _settingsUtils = new SiteSettingsUtils(_context); }
public UnitOfWork(WebDataContext context) { _context = context; UserRepository = new UserRepository(_context); RoleRepository = new GenericRepository <Role>(_context); }
public ImportTools(WebDataContext context) { _context = context; }
public UserRepository(WebDataContext context) : base(context) { }
public CategoryRepository(WebDataContext context) : base(context) { }
public LatestBlogsViewModel(int blogCount = 10) { Context = new WebDataContext(); Blogs = Context.Blogs.OrderByDescending(x => x.Date).Take(blogCount).ToList(); }
public SubscriberManager(WebDataContext context, Emailer emailer) { this._context = context; this._emailer = emailer; }
public IpLogger(WebDataContext context, Emailer emailer) { this._context = context; this._emailer = emailer; }
public WebDatasController(WebDataContext context) { _context = context; }
public GenericRepository(WebDataContext context) { Context = context; }
public EditContentHelper(WebDataContext context) { _context = context; _navigationUtils = new AdminNavigationUtils(context); }
public WebUserUtils(WebDataContext context) { Context = context; }
public GenericRepository(WebDataContext context) { _context = context; _dbSet = context.Set <TEntity>(); }
public ProductRepository(WebDataContext context) : base(context) { }