Beispiel #1
0
        protected void Application_Start()
        {
            //AjaxHelper.GlobalizationScriptPath = "http://ajax.microsoft.com/ajax/4.0/1/globalization/";

            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            ViewEngines.Engines.Add(new MobileCapableWebFormViewEngine());

            InitContainer();

            // The following lines trigger the creation of
            // the security database file
            // aspnetdb.mdf, if it does not exist.
            // This assumes that the database used is SQL Express
            // (that is the default, as per machine.config).
            // You must still add the users to their roles.
            // You can do this by using the ASP.NET Configuration tool.
            if (!Roles.RoleExists(Constants.AdminRole))
            {
                Roles.CreateRole(Constants.AdminRole);
            }
            if (!Roles.RoleExists(Constants.WriterRole))
            {
                Roles.CreateRole(Constants.WriterRole);
            }

            string[] administrators = Roles.GetUsersInRole(Constants.AdminRole);
            if (administrators.Length == 0)
            {
                createDefaultAdminUser();
            }

            IBus bus      = new Bus();
            var  storage  = new EventStore(bus);
            var  repo     = new Repository <CustomPage>(storage);
            var  commands = new CustomPageCommandHandlers(new CustomPageRepository(new DatabaseFactory()), repo);

            bus.RegisterHandler <CreateCustomPage>(commands.Handle);
            bus.RegisterHandler <UpdateCustomPage>(commands.Handle);
            bus.RegisterHandler <DeleteCustomPage>(commands.Handle);

            var customPageReporting = new CustomPageEventHandlers();

            bus.RegisterHandler <CustomPageCreated>(customPageReporting.Handle);
            bus.RegisterHandler <CustomPageDeleted>(customPageReporting.Handle);
            bus.RegisterHandler <CustomPageUpdated>(customPageReporting.Handle);

            ServiceLocator.Bus = bus;
        }
Beispiel #2
0
        public static void Run()
        {
            IBus bus      = new Bus();
            var  storage  = new EventStore(bus);
            var  repo     = new Repository <CustomPage>(storage);
            var  commands = new CustomPageCommandHandlers(new CustomPageRepository(new DatabaseFactory()), repo);

            bus.RegisterHandler <CreateCustomPage>(commands.Handle);
            bus.RegisterHandler <UpdateCustomPage>(commands.Handle);
            bus.RegisterHandler <DeleteCustomPage>(commands.Handle);

            var customPageReporting = new CustomPageEventHandlers();

            bus.RegisterHandler <CustomPageCreated>(customPageReporting.Handle);
            bus.RegisterHandler <CustomPageDeleted>(customPageReporting.Handle);
            bus.RegisterHandler <CustomPageUpdated>(customPageReporting.Handle);

            ServiceLocator.Bus = bus;
        }