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

            var item = order.Items.Single(x => x.ProductId == e.ProductId);

            item.Price    = e.Price;
            order.Updated = e.Stamp;

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

            var item = await ctx.UoW().Get <Entities.Item.Models.OrderingOrderItem>(Entities.Item.Handler.ItemIdGenerator(e.OrderId, e.ProductId)).ConfigureAwait(false);

            order.SubTotal -= item.SubTotal;

            item.Price = e.Price;

            order.SubTotal += item.SubTotal;
            order.Updated   = e.Stamp;

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

            var orderItem = await ctx.UoW().Get <Entities.Item.Models.OrderingOrderItem>(Entities.Item.Handler.ItemIdGenerator(e.OrderId, e.ProductId)).ConfigureAwait(false);

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

            // remove existing value
            existing.Value -= orderItem.Total;

            orderItem.Price = e.Price;

            // add updated total
            existing.Value += orderItem.Total;

            await ctx.UoW().Update(existing.Id, existing).ConfigureAwait(false);
        }