Пример #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();
        }