Example #1
0
        public void CustomAttributeRestoredEvent_Ctor_Should_Set_Arguments_Correctly()
        {
            Guid attributeId = Guid.NewGuid();
            var  @event      = new CustomAttributeRestoredEvent(attributeId);

            Assert.Equal(attributeId, @event.AttributeId);

            Assert.Equal(attributeId, @event.AggregateId);
            Assert.Equal(typeof(Catalog.Models.CustomAttribute), @event.AggregateType);
        }
Example #2
0
 /// <summary>
 /// <see cref="IHandleEvent{TEvent}.Handle(TEvent)"/>
 /// </summary>
 /// <param name="event"></param>
 public void Handle(CustomAttributeRestoredEvent @event)
 {
     try
     {
         EventStore.Save(@event);
     }
     catch
     {
         throw;
     }
 }
Example #3
0
        public async Task RestoreCustomAttribute(Guid attributeId)
        {
            try
            {
                var attribute = await Repository.GetByKeyAsync <CustomAttribute>(attributeId);

                attribute.Restore();

                await Repository.SaveChangesAsync();

                var @event = new CustomAttributeRestoredEvent(attributeId);
                EventBus.RaiseEvent(@event);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// Implementation of <see cref="ICustomAttributesCommands.RestoreCustomAttribute(Guid)"/>
        /// </summary>
        /// <param name="attributeId">The custom attribute id</param>
        /// <returns></returns>
        public async Task RestoreCustomAttribute(Guid attributeId)
        {
            try
            {
                if (attributeId == Guid.Empty)
                {
                    throw new ArgumentException("value cannot be empty", nameof(attributeId));
                }

                var attribute = await Repository.GetByKeyAsync <CustomAttribute>(attributeId);

                attribute.Restore();

                await Repository.SaveChangesAsync();

                var @event = new CustomAttributeRestoredEvent(attributeId);
                EventBus.RaiseEvent(@event);
            }
            catch
            {
                throw;
            }
        }