コード例 #1
0
ファイル: Program.cs プロジェクト: decarufe/SimpleCQRS-1
        private void Run()
        {
            runtime = new SampleRunTime(CONNECTION_STRING);
            runtime.Start();

            // Configure dependencies
            System.Data.Entity.Database.SetInitializer<SqlBankContext>(new System.Data.Entity.DropCreateDatabaseIfModelChanges<SqlBankContext>());
            var db = new SqlBankContext(CONNECTION_STRING);
            runtime.ServiceLocator.Register(db);

            // Get the Command Bus
            commandBus = runtime.ServiceLocator.Resolve<ICommandBus>();
            // Create and send a couple of command
            var accountReportReadModel = runtime.ServiceLocator.Resolve<AccountReportReadService>();
            var accounts = accountReportReadModel.GetAccounts();
            if (accounts.Count() == 0)
            {
                Console.WriteLine("Adding initial data...\n\n\n");
                var cmdMarcus = new CreateAccountCommand { FirstName = "Marcus", LastName = "Hammarberg" };
                var cmdDarren = new CreateAccountCommand { FirstName = "Darren", LastName = "Cauthon" };
                var cmdTyrone = new CreateAccountCommand { FirstName = "Tyrone", LastName = "Groves" };
                commandBus.Send(cmdMarcus);
                commandBus.Send(cmdDarren);
                commandBus.Send(cmdTyrone);
            }

            ProcessMenu();

            runtime.Shutdown();

            Console.ReadLine();
        }
コード例 #2
0
 public AccountReportReadService(SqlBankContext dbContext)
 {
     this.dbContext = dbContext;
 }