Exemplo n.º 1
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Starting application...");
            Console.WriteLine("Adding CQRS...");

            var services = CQRSBooter.CreateServiceCollectionWithLogger();

            services
            .AddEventSource()
            .AddDenormalizer();

            var serviceProvider = services.BuildServiceProvider();

            var repo = serviceProvider.GetRequiredService <IDomainObjectRepository>();

            var customer = CreateCustomerObject();
            await repo.SaveAsync(customer);

            var persistedCustomer = await repo.Get <Customer>(customer.Id);

            Console.WriteLine($"Persisted customer name: {persistedCustomer.State<NameState>().Name}");
        }
Exemplo n.º 2
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Starting application...");
            Console.WriteLine("Adding CQRS...");
            string url = "mongodb://localhost:27017/";

            Console.WriteLine(url);
            IMongoDatabase mongodb  = new MongoClient(url).GetDatabase("hellobecqrs");
            var            repo     = CQRSBooter.AddCqrs(mongodb);
            var            id       = Randomizer.Next();
            var            customer = new Customer(id.ToString());

            customer.CreateNewCustomer(new CreateCustomerFromConsoleCommand()
            {
                Name = "Contoso"
            });
            await repo.SaveAsync(customer);

            var persistedCustomer = await repo.Get <Customer>(id.ToString());

            Console.WriteLine($"Persisted customer name: {persistedCustomer.State<NameState>().Name}");
        }