protected virtual ISellableInventoryItemStateCreated Map(ICreateSellableInventoryItem c) { var stateEventId = new SellableInventoryItemEventId(c.SellableInventoryItemId, c.Version); ISellableInventoryItemStateCreated e = NewSellableInventoryItemStateCreated(stateEventId); e.CommandId = c.CommandId; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); var version = c.Version; decimal sellableQuantity = default(decimal); foreach (ICreateSellableInventoryItemEntry innerCommand in c.Entries) { ThrowOnInconsistentCommands(c, innerCommand); ISellableInventoryItemEntryStateCreated innerEvent = MapCreate(innerCommand, c, version, _state); e.AddSellableInventoryItemEntryEvent(innerEvent); sellableQuantity = sellableQuantity + (innerEvent.SellableQuantity != null ? innerEvent.SellableQuantity.GetValueOrDefault() : default(decimal)); } e.SellableQuantity = sellableQuantity; return(e); }
void ISellableInventoryItemApplicationService.When(ICreateSellableInventoryItem c) { this.When((CreateSellableInventoryItemDto)c); }
public virtual void Create(ICreateSellableInventoryItem c) { ISellableInventoryItemStateCreated e = Map(c); Apply(e); }
public virtual void When(ICreateSellableInventoryItem c) { Update(c, ar => ar.Create(c)); }