Exemplo n.º 1
0
        protected virtual IInventoryItemRequirementStateCreated Map(ICreateInventoryItemRequirement c)
        {
            var stateEventId = new InventoryItemRequirementEventId(c.InventoryItemRequirementId, c.Version);
            IInventoryItemRequirementStateCreated e = NewInventoryItemRequirementStateCreated(stateEventId);

            e.CommandId = c.CommandId;


            e.CreatedBy = (string)c.RequesterId;
            e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>();
            var version = c.Version;

            decimal quantity = default(decimal);

            foreach (ICreateInventoryItemRequirementEntry innerCommand in c.Entries)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IInventoryItemRequirementEntryStateCreated innerEvent = MapCreate(innerCommand, c, version, _state);
                e.AddInventoryItemRequirementEntryEvent(innerEvent);
                quantity = quantity + (innerEvent.Quantity != null ? innerEvent.Quantity.GetValueOrDefault() : default(decimal));
            }

            e.Quantity = quantity;

            return(e);
        }
 public virtual void When(ICreateInventoryItemRequirement c)
 {
     Update(c, ar => ar.Create(c));
 }
Exemplo n.º 3
0
        public virtual void Create(ICreateInventoryItemRequirement c)
        {
            IInventoryItemRequirementStateCreated e = Map(c);

            Apply(e);
        }
Exemplo n.º 4
0
 void IInventoryItemRequirementApplicationService.When(ICreateInventoryItemRequirement c)
 {
     this.When((CreateInventoryItemRequirementDto)c);
 }