コード例 #1
0
        public async Task Handle(Commands.ClaimBasket command, IMessageHandlerContext ctx)
        {
            var basket = await ctx.For <Basket>().Get(command.BasketId).ConfigureAwait(false);

            var user = await ctx.For <Identity.User.User>().Get(command.UserName).ConfigureAwait(false);

            basket.Claim(user.State);
        }
コード例 #2
0
        public async Task Handle(Commands.Add command, IMessageHandlerContext ctx)
        {
            var location = await ctx.For <Location>().New(command.LocationId).ConfigureAwait(false);

            var parent = await ctx.For <Location>().TryGet(command.ParentId).ConfigureAwait(false);

            location.Add(command.Code, command.Description, parent?.State);
        }
コード例 #3
0
        public async Task Handle(Commands.Remove command, IMessageHandlerContext ctx)
        {
            var buyer = await ctx.For <Buyer>().Get(command.UserName).ConfigureAwait(false);

            var method = await ctx.For <PaymentMethod>().Get(command.PaymentMethodId).ConfigureAwait(false);

            method.Remove();
        }
コード例 #4
0
        public async Task Handle(Commands.Remove command, IMessageHandlerContext ctx)
        {
            var order = await ctx.For <Order>().Get(command.OrderId).ConfigureAwait(false);

            var item = await ctx.For <Item>().Get(command.ProductId).ConfigureAwait(false);

            item.Remove();
        }
コード例 #5
0
        public async Task Handle(Commands.Add command, IMessageHandlerContext ctx)
        {
            var order = await ctx.For <Order>().Get(command.OrderId).ConfigureAwait(false);

            var item = await ctx.For <Item>().New(command.ProductId).ConfigureAwait(false);

            item.Add(command.Quantity);
        }
コード例 #6
0
        public async Task Handle(Commands.Initiate command, IMessageHandlerContext ctx)
        {
            var basket = await ctx.For <Basket>().New(command.BasketId).ConfigureAwait(false);

            var user = await ctx.For <Identity.User.User>().TryGet(command.UserName).ConfigureAwait(false);

            basket.Initiate(user?.State);
        }
コード例 #7
0
        public async Task Handle(Commands.Remove command, IMessageHandlerContext ctx)
        {
            var buyer = await ctx.For <Buyer>().Get(command.UserName).ConfigureAwait(false);

            var address = await ctx.For <Address>().Get(command.AddressId).ConfigureAwait(false);

            address.Remove();
        }
コード例 #8
0
        public async Task Handle(Commands.Record command, IMessageHandlerContext ctx)
        {
            var record = await ctx.For <User>().New(command.RecordId).ConfigureAwait(false);

            var location = await ctx.For <Location.Location>().Get(command.LocationId).ConfigureAwait(false);

            var user = await ctx.For <Identity.User.User>().Get(command.UserId).ConfigureAwait(false);

            record.Record(location.State, user.State);
        }
コード例 #9
0
        public async Task Handle(Commands.Add command, IMessageHandlerContext ctx)
        {
            var product = await ctx.For <Product>().New(command.ProductId).ConfigureAwait(false);

            var brand = await ctx.For <CatalogBrand.Brand>().Get(command.CatalogBrandId).ConfigureAwait(false);

            var type = await ctx.For <CatalogType.Type>().Get(command.CatalogTypeId).ConfigureAwait(false);

            product.Add(command.Name, command.Price, brand.State, type.State);
        }
コード例 #10
0
        public async Task Handle(Commands.ChangePaymentMethod command, IMessageHandlerContext ctx)
        {
            var order = await ctx.For <Order>().Get(command.OrderId).ConfigureAwait(false);

            var buyer = await ctx.For <Buyer.Buyer>().Get(order.State.UserName).ConfigureAwait(false);

            var method = await ctx.For <Buyer.Entities.PaymentMethod.PaymentMethod>().Get(command.PaymentMethodId).ConfigureAwait(false);

            order.ChangePaymentMethod(method.State);
        }
コード例 #11
0
        public async Task Handle(SayHello command, IMessageHandlerContext ctx)
        {
            var world = await ctx.For <World>().TryGet("World");

            if (world == null)
            {
                world = await ctx.For <World>().New("World");
            }

            world.SayHello(command.Message);
        }
コード例 #12
0
        public async Task Handle(Commands.Charge command, IMessageHandlerContext ctx)
        {
            var payment = await ctx.For <Payment>().New(command.PaymentId).ConfigureAwait(false);

            var buyer = await ctx.For <Ordering.Buyer.Buyer>().Get(command.UserName).ConfigureAwait(false);

            var order = await ctx.For <Ordering.Order.Order>().Get(command.OrderId).ConfigureAwait(false);

            var method = await buyer.For <Ordering.Buyer.Entities.PaymentMethod.PaymentMethod>().Get(command.PaymentMethodId).ConfigureAwait(false);

            payment.Charge(buyer.State, order.State, method.State);
        }
コード例 #13
0
        public async Task Handle(Commands.ChangeAddress command, IMessageHandlerContext ctx)
        {
            var order = await ctx.For <Order>().Get(command.OrderId).ConfigureAwait(false);

            var buyer = await ctx.For <Buyer.Buyer>().Get(order.State.UserName).ConfigureAwait(false);

            var shipping = await ctx.For <Buyer.Entities.Address.Address>().Get(command.ShippingId).ConfigureAwait(false);

            var billing = await ctx.For <Buyer.Entities.Address.Address>().Get(command.BillingId).ConfigureAwait(false);

            order.ChangeAddress(shipping.State, billing.State);
        }
コード例 #14
0
        public async Task Handle(SayHello command, IMessageHandlerContext ctx)
        {
            var world = await ctx.For <World>().TryGet("World");

            if (world == null)
            {
                world = await ctx.For <World>().New("World");

                world.Create();
            }

            var message = await world.For <Message>().New(Guid.NewGuid());

            message.SayHello(command.Message);
        }
コード例 #15
0
        public async Task Handle(Commands.AddItem command, IMessageHandlerContext ctx)
        {
            var basket = await ctx.For <Basket>().Get(command.BasketId).ConfigureAwait(false);

            // allow user to add product, remove product, re-add product
            var item = await basket.For <Item>().TryGet(command.ProductId).ConfigureAwait(false);

            if (item == null)
            {
                item = await basket.For <Item>().New(command.ProductId).ConfigureAwait(false);
            }

            var product = await ctx.For <Catalog.Product.Product>().Get(command.ProductId).ConfigureAwait(false);

            item.Add();
        }
コード例 #16
0
        public async Task Handle(Commands.Draft command, IMessageHandlerContext ctx)
        {
            var buyer = await ctx.For <Buyer.Buyer>().Get(command.UserName).ConfigureAwait(false);

            var basket = await ctx.For <Basket.Basket.Basket>().Get(command.BasketId).ConfigureAwait(false);

            var order = await ctx.For <Order>().New(command.OrderId).ConfigureAwait(false);

            var shipping = await buyer.For <Buyer.Entities.Address.Address>().Get(command.ShippingAddressId).ConfigureAwait(false);

            var billing = await buyer.For <Buyer.Entities.Address.Address>().Get(command.BillingAddressId).ConfigureAwait(false);

            var method = await buyer.For <Buyer.Entities.PaymentMethod.PaymentMethod>().Get(command.PaymentMethodId).ConfigureAwait(false);

            order.Draft(buyer.State, basket.State, shipping.State, billing.State, method.State);
        }
コード例 #17
0
        public async Task Handle(Commands.RemoveItem command, IMessageHandlerContext ctx)
        {
            var basket = await ctx.For <Basket>().Get(command.BasketId).ConfigureAwait(false);

            var item = await basket.For <Item>().Get(command.ProductId).ConfigureAwait(false);

            item.Remove();
        }
コード例 #18
0
        public async Task Handle(Commands.Add command, IMessageHandlerContext ctx)
        {
            var buyer = await ctx.For <Buyer>().Get(command.UserName).ConfigureAwait(false);

            var address = await buyer.For <Address>().New(command.AddressId).ConfigureAwait(false);

            address.Add(command.Alias, command.Street, command.City, command.State, command.Country, command.ZipCode);
        }
コード例 #19
0
        public async Task Handle(Commands.Remove command, IMessageHandlerContext ctx)
        {
            var location = await ctx.For <Location>().Get(command.LocationId).ConfigureAwait(false);

            var point = await location.For <Point>().Get(command.PointId).ConfigureAwait(false);

            point.Remove();
        }
コード例 #20
0
        public async Task Handle(Commands.Add command, IMessageHandlerContext ctx)
        {
            var location = await ctx.For <Location>().Get(command.LocationId).ConfigureAwait(false);

            var point = await location.For <Point>().New(command.PointId).ConfigureAwait(false);

            point.Add(command.Longitude, command.Latitude);
        }
コード例 #21
0
        public async Task Handle(Commands.Revoke command, IMessageHandlerContext ctx)
        {
            var user = await ctx.For <User>().Get(command.UserName).ConfigureAwait(false);

            var role = await user.For <Role>().Get(command.RoleId).ConfigureAwait(false);

            role.Revoke();
        }
コード例 #22
0
        public async Task Handle(Commands.Add command, IMessageHandlerContext ctx)
        {
            var campaign = await ctx.For <Campaign>().Get(command.CampaignId).ConfigureAwait(false);

            var rule = await campaign.For <Rule>().New(command.RuleId).ConfigureAwait(false);

            rule.Add(command.Description);
        }
コード例 #23
0
        public async Task Handle(Commands.UpdateQuantity command, IMessageHandlerContext ctx)
        {
            var basket = await ctx.For <Basket>().Get(command.BasketId).ConfigureAwait(false);

            var item = await basket.For <Item>().Get(command.ProductId).ConfigureAwait(false);

            item.UpdateQuantity(command.Quantity);
        }
コード例 #24
0
        public async Task Handle(Commands.SetPreferredPaymentMethod command, IMessageHandlerContext ctx)
        {
            var buyer = await ctx.For <Buyer>().Get(command.UserName).ConfigureAwait(false);

            var method = await buyer.For <Entities.PaymentMethod.PaymentMethod>().Get(command.PaymentMethodId).ConfigureAwait(false);

            buyer.SetPreferredPaymentMethod(method.State);
        }
コード例 #25
0
        public async Task Handle(Commands.SetPreferredAddress command, IMessageHandlerContext ctx)
        {
            var buyer = await ctx.For <Buyer>().Get(command.UserName).ConfigureAwait(false);

            var address = await buyer.For <Entities.Address.Address>().Get(command.AddressId).ConfigureAwait(false);

            buyer.SetPreferredAddress(address.State);
        }
コード例 #26
0
        public async Task Handle(Commands.Remove command, IMessageHandlerContext ctx)
        {
            var campaign = await ctx.For <Campaign>().Get(command.CampaignId).ConfigureAwait(false);

            var rule = await campaign.For <Rule>().Get(command.RuleId).ConfigureAwait(false);

            rule.Remove();
        }
コード例 #27
0
        public async Task Handle(Commands.Add command, IMessageHandlerContext ctx)
        {
            var buyer = await ctx.For <Buyer>().Get(command.UserName).ConfigureAwait(false);

            var method = await buyer.For <PaymentMethod>().New(command.PaymentMethodId).ConfigureAwait(false);

            method.Add(command.Alias, command.CardNumber, command.SecurityNumber, command.CardholderName,
                       command.Expiration, command.CardType);
        }
コード例 #28
0
        public async Task Handle(Commands.Seed command, IMessageHandlerContext ctx)
        {
            var setup = await ctx.For <Setup>().Get("setup").ConfigureAwait(false);

            var users = await setup.For <Identity>().New("identity").ConfigureAwait(false);

            await Import.Seed(ctx).ConfigureAwait(false);

            users.Seeded();
        }
コード例 #29
0
        public async Task Handle(Commands.Seed command, IMessageHandlerContext ctx)
        {
            var setup = await ctx.For <Setup>().Get("setup").ConfigureAwait(false);

            var ordering = await setup.For <Orders>().New("ordering").ConfigureAwait(false);

            await Import.Seed(ctx).ConfigureAwait(false);

            ordering.Seeded();
        }
コード例 #30
0
        public async Task Handle(Commands.Seed command, IMessageHandlerContext ctx)
        {
            var setup = await ctx.For <Setup>().Get("setup").ConfigureAwait(false);

            var basket = await setup.For <Basket>().New("basket").ConfigureAwait(false);

            await Import.Seed(ctx).ConfigureAwait(false);

            basket.Seeded();
        }