/// <summary>
        /// Implementation of <see cref="IProductCommands.RemoveTierPriceFromProduct(Guid, Guid)"/>
        /// </summary>
        /// <param name="productId">The product id</param>
        /// <param name="tierPriceId">The tier price id</param>
        /// <returns></returns>
        public virtual async Task RemoveTierPriceFromProduct(Guid productId, Guid tierPriceId)
        {
            try
            {
                if (productId == Guid.Empty)
                {
                    throw new ArgumentException("value cannot be empty", nameof(productId));
                }

                if (tierPriceId == Guid.Empty)
                {
                    throw new ArgumentException("value cannot be empty", nameof(tierPriceId));
                }

                var product = await Repository.GetByKeyAsync <Product>(productId);

                product.DeleteTierPrice(tierPriceId);

                await Repository.SaveChangesAsync();

                var @event = new ProductTierPriceRemovedEvent(productId, tierPriceId);
                EventBus.RaiseEvent(@event);
            }
            catch
            {
                throw;
            }
        }
Esempio n. 2
0
 public void Handle(ProductTierPriceRemovedEvent @event)
 {
     try
     {
         EventStore.Save(@event);
     }
     catch
     {
         throw;
     }
 }
        public void ProductTierPriceRemovedEvent_Ctor_Should_Set_Arguments_Correctly()
        {
            Guid productId   = Guid.NewGuid();
            Guid tierPriceId = Guid.NewGuid();

            var @event = new ProductTierPriceRemovedEvent(productId, tierPriceId);

            Assert.Equal(productId, @event.ProductId);
            Assert.Equal(tierPriceId, @event.TierPriceId);

            Assert.Equal(productId, @event.AggregateId);
            Assert.Equal(typeof(Catalog.Models.Product), @event.AggregateType);
        }
Esempio n. 4
0
        public async Task RemoveTierPriceFromProduct(Guid productId, Guid tierPriceId)
        {
            try
            {
                var product = await Repository.GetByKeyAsync <Product>(productId);

                product.DeleteTierPrice(tierPriceId);

                await Repository.SaveChangesAsync();

                var @event = new ProductTierPriceRemovedEvent(productId, tierPriceId);
                EventBus.RaiseEvent(@event);
            }
            catch
            {
                throw;
            }
        }