예제 #1
0
파일: Startup.cs 프로젝트: vnextcoder/CQRS
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });
            // Build the WRITE side (we use a bus for it) ----------
            var bus = new FakeBus();
            var bookingRepository = new BookingAndClientsRepository();

            var bookingHandler = CompositionRootHelper.BuildTheWriteModelHexagon(bookingRepository, bookingRepository, bus, bus);

            // TODO: register handlers for the query part coming from the bus?

            // Build the READ side ---------------------------------
            var hotelsAdapter = new HotelsAndRoomsAdapter($"{env.WebRootPath}/hotels/", bus);

            hotelsAdapter.LoadAllHotelsFiles();

            var readFacade = CompositionRootHelper.BuildTheReadModelHexagon(hotelsAdapter, hotelsAdapter, null, bus);

            // Registers all services to the MVC IoC framework
            services.AddSingleton <ISendCommands>(bus);
            services.AddSingleton <IQueryBookingOptions>(readFacade);
            services.AddSingleton <IProvideHotel>(readFacade);
            services.AddSingleton <IProvideReservations>(readFacade);


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
예제 #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Build the WRITE side (we use a bus for it) ----------
            var bus = new FakeBus();
            var bookingRepository = new BookingAndClientsRepository();

            var bookingHandler = CompositionRootHelper.BuildTheWriteModelHexagon(bookingRepository, bookingRepository, bus, bus);

            // TODO: register handlers for the query part coming from the bus?

            // Build the READ side ---------------------------------
            var hotelsAdapter = new HotelsAndRoomsAdapter($"{env.WebRootPath}/hotels/", bus);

            hotelsAdapter.LoadAllHotelsFiles();

            var readFacade = CompositionRootHelper.BuildTheReadModelHexagon(hotelsAdapter, hotelsAdapter, null, bus);

            // Registers all services to the MVC IoC framework
            services.AddSingleton <ISendCommands>(bus);
            services.AddSingleton <IQueryBookingOptions>(readFacade);
            services.AddSingleton <IProvideHotel>(readFacade);
            services.AddSingleton <IProvideReservations>(readFacade);

            // Add framework services.
            services.AddMvc();
        }
예제 #3
0
        public void Should_load_all_files()
        {
            var hotelsAdapter = new HotelsAndRoomsAdapter(Constants.RelativePathForHotelIntegrationFiles, new FakeBus());

            hotelsAdapter.LoadAllHotelsFiles();

            Check.That(hotelsAdapter.Hotels).HasSize(4);
        }