Esempio n. 1
0
        public async Task <ProductPurchase> PurchaseProduct(ProductPurchase productPurchase,
                                                            [Service] IMediator mediator,
                                                            [Service] ILogger <ProductPurchaseMutation> logger)
        {
            try
            {
                var purchaseCommand = new ProductPurchaseCommand()
                {
                    ProductPurchase = productPurchase
                };

                return(await mediator.Send(purchaseCommand));

                //messageBus.DeclareExchange("MyShop", "topic");
                //if (messageBus.PublishMessage(new { userId, shopId, productType }, "PurchaseProduct", "MyShop"))
                //{
                //    return true;
                //}
            }
            catch (Exception ex)
            {
                logger.LogError(LoggerEvents.GenerateEventId(LoggerEventType.UnknownPurchaseProductMutationException),
                                ex,
                                $"{nameof(ProductPurchaseMutation)} PurchaseProduct encountered exception with ShopId: {productPurchase.ShopId},ProductType: {productPurchase.ProductType},UserId: {productPurchase.UserId}");

                throw;
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Clears all captured events
 /// </summary>
 public void Clear()
 {
     lock (LoggerEvents)
     {
         ClearLastEvent();
         LoggerEvents.Clear();
     }
 }
Esempio n. 3
0
 public void Clear()
 {
     lock (LoggerEvents)
     {
         lastEvent = null;
         LoggerEvents.Clear();
     }
 }
Esempio n. 4
0
 protected override void HandleMessage(ProductPurchase message)
 {
     if (_productPurchaseHandler == null)
     {
         _logger.LogWarning(
             LoggerEvents.GenerateEventId(LoggerEventType.MissingMessageBusDomainHandler),
             $"{nameof(MessageBusProductPurchaseHandler)}: IProductPurchaseHandler is not registered");
         return;
     }
     _productPurchaseHandler.HandleProductPurchase(message);
 }
Esempio n. 5
0
 private static EventId GetEventId(LoggerEvents @event) => new EventId((int)@event, @event.ToString());