Ejemplo n.º 1
0
        /// <summary>
        /// Implementation of <see cref="ICustomerCommands.RemoveCustomerBillingInformation(Guid, Guid)"/>
        /// </summary>
        /// <param name="customerId">The customer id</param>
        /// <param name="billingInfoId">The billing info id</param>
        /// <returns></returns>
        public async Task RemoveCustomerBillingInformation(Guid customerId, Guid billingInfoId)
        {
            if (customerId == Guid.Empty)
            {
                throw new ArgumentException("value cannot be empty", nameof(customerId));
            }

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

            var customer = await Repository.GetByKeyAsync <Customer>(customerId);

            if (customer == null)
            {
                throw new ArgumentOutOfRangeException(nameof(customerId));
            }

            customer.RemoveBillingInfo(billingInfoId);
            await Repository.SaveChangesAsync();

            var @event = new BillingoInformationRemovedEvent(customerId, billingInfoId);

            EventBus.RaiseEvent(@event);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// <see cref="IHandleEvent{TEvent}.Handle(TEvent)"/>
 /// </summary>
 /// <param name="event"></param>
 public void Handle(BillingoInformationRemovedEvent @event)
 {
     try
     {
         EventStore.Save(@event);
     }
     catch
     {
         throw;
     }
 }
        public void ToString_Should_Return_Event_Formatted_As_String()
        {
            Guid customerId    = Guid.NewGuid();
            Guid billingInfoId = Guid.NewGuid();

            var ev = new BillingoInformationRemovedEvent(customerId, billingInfoId);

            string eventAsString = $"Billing info {billingInfoId} removed from customer {customerId}";

            Assert.Equal(eventAsString, ev.ToString());
        }
        public void Ctor_Should_Set_All_Values_Correctly()
        {
            Guid customerId    = Guid.NewGuid();
            Guid billingInfoId = Guid.NewGuid();

            var ev = new BillingoInformationRemovedEvent(customerId, billingInfoId);

            Assert.Equal(customerId, ev.CustomerId);
            Assert.Equal(billingInfoId, ev.BillingInfoId);

            Assert.Equal(customerId, ev.AggregateId);
            Assert.Equal(typeof(Registries.Models.Customer), ev.AggregateType);
        }