Esempio n. 1
0
        public async Task Handle(Order.Events.Drafted e, IMessageHandlerContext ctx)
        {
            // get all items in basket
            var itemIds = await ctx.Service <Basket.Basket.Entities.Item.Services.ItemsInBasket, string[]>(x => { x.BasketId = e.BasketId; })
                          .ConfigureAwait(false);

            // add the items to order
            foreach (var id in itemIds)
            {
                var item = await ctx.UoW().Get <Basket.Basket.Entities.Item.Models.BasketItemIndex>(id).ConfigureAwait(false);

                var model = new Models.OrderingOrderItem
                {
                    Id                        = ItemIdGenerator(e.OrderId, item.ProductId),
                    OrderId                   = e.OrderId,
                    ProductId                 = item.ProductId,
                    ProductName               = item.ProductName,
                    ProductDescription        = item.ProductDescription,
                    ProductPictureContents    = item.ProductPictureContents,
                    ProductPictureContentType = item.ProductPictureContentType,
                    ProductPrice              = item.ProductPrice,
                    Quantity                  = item.Quantity,
                };

                await ctx.UoW().Add(model.Id, model).ConfigureAwait(false);
            }
        }
Esempio n. 2
0
        public async Task Handle(Events.Added e, IMessageHandlerContext ctx)
        {
            var product = await ctx.UoW()
                          .Get <Catalog.Product.Models.CatalogProduct>(e.ProductId).ConfigureAwait(false);

            var model = new Models.OrderingOrderItem
            {
                Id                        = ItemIdGenerator(e.OrderId, e.ProductId),
                OrderId                   = e.OrderId,
                ProductId                 = e.ProductId,
                ProductName               = product.Name,
                ProductDescription        = product.Description,
                ProductPictureContents    = product.PictureContents,
                ProductPictureContentType = product.PictureContentType,
                ProductPrice              = product.Price,
                Quantity                  = e.Quantity
            };

            await ctx.UoW().Add(model.Id, model).ConfigureAwait(false);
        }