Example #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();
            SettingsInitializer.EnsureRequiredSettingsExist();
        }
 public static void EnsureRequiredSettingsExist()
 {
     using (var context = new WebDataContext())
     {
         InitSiteSettings(context);
         InitTimeZone(context);
         context.SaveChanges();
     }
 }
Example #3
0
        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);
    }
Example #6
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;
            }
        }
Example #7
0
 public BlogLoader(WebDataContext context = null)
 {
     _context       = context ?? new WebDataContext();
     _settingsUtils = new SiteSettingsUtils(_context);
 }
Example #8
0
 public UnitOfWork(WebDataContext context)
 {
     _context       = context;
     UserRepository = new UserRepository(_context);
     RoleRepository = new GenericRepository <Role>(_context);
 }
Example #9
0
 public ImportTools(WebDataContext context)
 {
     _context = context;
 }
Example #10
0
 public UserRepository(WebDataContext context) : base(context)
 {
 }
Example #11
0
 public CategoryRepository(WebDataContext context) : base(context)
 {
 }
Example #12
0
 public LatestBlogsViewModel(int blogCount = 10)
 {
     Context = new WebDataContext();
     Blogs   = Context.Blogs.OrderByDescending(x => x.Date).Take(blogCount).ToList();
 }
Example #13
0
 public SubscriberManager(WebDataContext context, Emailer emailer)
 {
     this._context = context;
     this._emailer = emailer;
 }
Example #14
0
 public IpLogger(WebDataContext context, Emailer emailer)
 {
     this._context = context;
     this._emailer = emailer;
 }
Example #15
0
 public WebDatasController(WebDataContext context)
 {
     _context = context;
 }
Example #16
0
 public GenericRepository(WebDataContext context)
 {
     Context = context;
 }
Example #17
0
 public EditContentHelper(WebDataContext context)
 {
     _context         = context;
     _navigationUtils = new AdminNavigationUtils(context);
 }
Example #18
0
 public WebUserUtils(WebDataContext context)
 {
     Context = context;
 }
Example #19
0
 public GenericRepository(WebDataContext context)
 {
     _context = context;
     _dbSet   = context.Set <TEntity>();
 }
 public ProductRepository(WebDataContext context) : base(context)
 {
 }