Exemple #1
0
        public async Task Consume(ConsumeContext <ShippingArranged> context)
        {
            var order = await _ordersRepository.Get(context.Message.OrderId);

            order.Status     = "Shipping arranged";
            order.LastUpdate = DateTime.UtcNow;

            await _dbContext.SaveChangesAsync();
        }
        public async Task Consume(ConsumeContext <PaymentAccepted> context)
        {
            var order = await _ordersRepository.Get(context.Message.OrderId);

            order.Status     = "Payment accepted";
            order.LastUpdate = DateTime.UtcNow;

            await _dbContext.SaveChangesAsync();
        }
        public async Task Consume(ConsumeContext <OrderPlaced> context)
        {
            await _ordersRepository.Add(new Order
            {
                Id         = context.Message.OrderId,
                Status     = "Placed",
                Number     = "",
                LastUpdate = context.Message.TimeStamp,
                UserId     = context.Message.UserId
            });

            await _dbContext.SaveChangesAsync();
        }
        public async Task Consume(ConsumeContext <OrderCreated> context)
        {
            var order = await _ordersRepository.Get(context.Message.OrderId);

            if (order == null)
            {
                throw new ArgumentNullException(nameof(context.Message.OrderId), "No such order with given id");
            }

            order.Status     = "Created";
            order.LastUpdate = DateTime.UtcNow;
            order.Number     = context.Message.Number;

            await _dbContext.SaveChangesAsync();
        }