コード例 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            //need the assembly to be loaded, need a better way
            var command = new CreateInventoryMasterCommand();

            services.AddDbContext <DomainDbContext>(options =>
                                                    options.UseSqlite("Data Source = domain.db"));
            //options.UseSqlServer(Configuration.GetConnectionString("DomainContext")));

            services.AddScoped <IDomainStore, DomainStore>();
            services.AddScoped <IEventStore>(provider => provider.GetService <IDomainStore>() as IEventStore);
            services.AddScoped <IUsernameProvider, StaticUsernameProvider>();

            //add the singleton services
            services.AddCqrs();
        }
コード例 #2
0
 public async Task <IActionResult> Create(CreateInventoryMasterCommand command)
 {
     return(await DispatchCommandAsync(command, c => RedirectToAction(nameof(Index))));
 }