Exemple #1
0
        public async Task Handle(Entities.Item.Events.Added e, IMessageHandlerContext ctx)
        {
            var order = await ctx.UoW().Get <Models.OrderingOrderIndex>(e.OrderId).ConfigureAwait(false);

            var product = await ctx.UoW().Get <Catalog.Product.Models.CatalogProductIndex>(e.ProductId).ConfigureAwait(false);

            var existing = await ctx.UoW().Get <Models.SalesChart>(IdGenerator(order.Created.FromUnix().Date)).ConfigureAwait(false);

            existing.Value += product.Price * e.Quantity;
            await ctx.UoW().Update(existing.Id, existing).ConfigureAwait(false);
        }
Exemple #2
0
        public async Task Handle(Entities.Item.Events.Added e, IMessageHandlerContext ctx)
        {
            var order = await ctx.UoW().Get <Models.OrderingOrderIndex>(e.OrderId).ConfigureAwait(false);

            var product = await ctx.UoW().Get <Catalog.Product.Models.CatalogProductIndex>(e.ProductId).ConfigureAwait(false);

            order.TotalItems++;
            order.TotalQuantity += e.Quantity;
            order.SubTotal      += (e.Quantity * product.Price);
            order.Updated        = e.Stamp;

            await ctx.UoW().Update(e.OrderId, order).ConfigureAwait(false);
        }
Exemple #3
0
        public async Task Handle(Entities.Item.Events.Added e, IMessageHandlerContext ctx)
        {
            var order = await ctx.UoW().Get <Models.OrderingOrderIndex>(e.OrderId).ConfigureAwait(false);

            var product = await ctx.UoW().Get <Catalog.Product.Models.CatalogProductIndex>(e.ProductId).ConfigureAwait(false);

            var day   = order.Created.FromUnix().Date;
            var month = new DateTime(day.Year, day.Month, 1);

            var existing = await ctx.UoW().Get <Models.SalesByState>(IdGenerator(month, order.ShippingState)).ConfigureAwait(false);

            existing.Value += product.Price * e.Quantity;
            await ctx.UoW().Update(existing.Id, existing).ConfigureAwait(false);
        }
Exemple #4
0
        public async Task Handle(Entities.Item.Events.Added e, IMessageHandlerContext ctx)
        {
            var order = await ctx.UoW().Get <Models.OrderingOrder>(e.OrderId).ConfigureAwait(false);

            var product = await ctx.UoW().Get <Catalog.Product.Models.CatalogProductIndex>(e.ProductId).ConfigureAwait(false);

            order.Items = order.Items.TryAdd(new Entities.Item.Models.OrderingOrderItem
            {
                Id                        = ItemIdGenerator(e.OrderId, e.ProductId),
                OrderId                   = e.OrderId,
                ProductId                 = product.Id,
                ProductName               = product.Name,
                ProductDescription        = product.Description,
                ProductPictureContents    = product.PictureContents,
                ProductPictureContentType = product.PictureContentType,
                ProductPrice              = product.Price,
                Quantity                  = e.Quantity
            }, x => x.Id);
            order.Updated = e.Stamp;

            await ctx.UoW().Update(e.OrderId, order).ConfigureAwait(false);
        }