public virtual InOutStateCreatedDto ToInOutStateCreatedDto(IInOutStateCreated e) { var dto = new InOutStateCreatedDto(); dto.InOutEventId = e.InOutEventId; dto.CreatedAt = e.CreatedAt; dto.CreatedBy = e.CreatedBy; dto.CommandId = e.CommandId; dto.DocumentStatusId = e.DocumentStatusId; dto.Posted = e.Posted; dto.Processed = e.Processed; dto.Processing = e.Processing; dto.DocumentTypeId = e.DocumentTypeId; dto.Description = e.Description; dto.OrderId = e.OrderId; dto.DateOrdered = e.DateOrdered; dto.IsPrinted = e.IsPrinted; dto.MovementTypeId = e.MovementTypeId; dto.MovementDate = e.MovementDate; dto.BusinessPartnerId = e.BusinessPartnerId; dto.WarehouseId = e.WarehouseId; dto.POReference = e.POReference; dto.FreightAmount = e.FreightAmount; dto.ShipperId = e.ShipperId; dto.ChargeAmount = e.ChargeAmount; dto.DatePrinted = e.DatePrinted; dto.CreatedFrom = e.CreatedFrom; dto.SalesRepresentativeId = e.SalesRepresentativeId; dto.NumberOfPackages = e.NumberOfPackages; dto.PickDate = e.PickDate; dto.ShipDate = e.ShipDate; dto.TrackingNumber = e.TrackingNumber; dto.DateReceived = e.DateReceived; dto.IsInTransit = e.IsInTransit; dto.IsApproved = e.IsApproved; dto.IsInDispute = e.IsInDispute; dto.RmaDocumentNumber = e.RmaDocumentNumber; dto.ReversalDocumentNumber = e.ReversalDocumentNumber; dto.Active = e.Active; var inOutImageEvents = new List <InOutImageStateCreatedDto>(); foreach (var ee in e.InOutImageEvents) { InOutImageStateCreatedDto eeDto = InOutImageStateEventDtoConverter.ToInOutImageStateCreatedDto(ee); inOutImageEvents.Add(eeDto); } dto.InOutImageEvents = inOutImageEvents.ToArray(); var inOutLineEvents = new List <InOutLineStateCreatedDto>(); foreach (var ee in e.InOutLineEvents) { InOutLineStateCreatedDto eeDto = InOutLineStateEventDtoConverter.ToInOutLineStateCreatedDto(ee); inOutLineEvents.Add(eeDto); } dto.InOutLineEvents = inOutLineEvents.ToArray(); return(dto); }
protected virtual IInOutStateCreated Map(ICreateInOut c) { var stateEventId = new InOutStateEventId(c.DocumentNumber, c.Version); IInOutStateCreated e = NewInOutStateCreated(stateEventId); e.IsSOTransaction = c.IsSOTransaction; NewInOutDocumentActionCommandAndExecute(c, _state, e); e.Posted = c.Posted; e.Processing = c.Processing; e.Processed = c.Processed; e.DocumentType = c.DocumentType; e.Description = c.Description; e.OrderNumber = c.OrderNumber; e.DateOrdered = c.DateOrdered; e.IsPrinted = c.IsPrinted; e.MovementType = c.MovementType; e.MovementDate = c.MovementDate; e.BusinessPartnerId = c.BusinessPartnerId; e.WarehouseId = c.WarehouseId; e.POReference = c.POReference; e.FreightAmount = c.FreightAmount; e.ShipperId = c.ShipperId; e.ChargeAmount = c.ChargeAmount; e.DatePrinted = c.DatePrinted; e.SalesRepresentative = c.SalesRepresentative; e.NumberOfPackages = c.NumberOfPackages; e.PickDate = c.PickDate; e.ShipDate = c.ShipDate; e.TrackingNumber = c.TrackingNumber; e.DateReceived = c.DateReceived; e.IsInTransit = c.IsInTransit; e.IsApproved = c.IsApproved; e.IsInDispute = c.IsInDispute; e.Volume = c.Volume; e.Weight = c.Weight; e.RmaNumber = c.RmaNumber; e.ReversalNumber = c.ReversalNumber; e.IsDropShip = c.IsDropShip; e.DropShipBusinessPartnerId = c.DropShipBusinessPartnerId; e.Active = c.Active; ReflectUtils.CopyPropertyValue("CommandId", c, e); e.CreatedBy = (string)c.RequesterId; e.CreatedAt = DateTime.Now; var version = c.Version; foreach (ICreateInOutLine innerCommand in c.InOutLines) { ThrowOnInconsistentCommands(c, innerCommand); IInOutLineStateCreated innerEvent = MapCreate(innerCommand, c, version, _state); e.AddInOutLineEvent(innerEvent); } return(e); }
protected virtual IInOutStateCreated Map(ICreateInOut c) { var stateEventId = new InOutEventId(c.DocumentNumber, c.Version); IInOutStateCreated e = NewInOutStateCreated(stateEventId); NewInOutDocumentActionCommandAndExecute(c, _state, e); e.Posted = c.Posted; e.Processed = c.Processed; e.Processing = c.Processing; e.DocumentTypeId = c.DocumentTypeId; e.Description = c.Description; e.OrderId = c.OrderId; e.DateOrdered = c.DateOrdered; e.IsPrinted = c.IsPrinted; e.MovementTypeId = c.MovementTypeId; e.MovementDate = c.MovementDate; e.BusinessPartnerId = c.BusinessPartnerId; e.WarehouseId = c.WarehouseId; e.POReference = c.POReference; e.FreightAmount = c.FreightAmount; e.ShipperId = c.ShipperId; e.ChargeAmount = c.ChargeAmount; e.DatePrinted = c.DatePrinted; e.CreatedFrom = c.CreatedFrom; e.SalesRepresentativeId = c.SalesRepresentativeId; e.NumberOfPackages = c.NumberOfPackages; e.PickDate = c.PickDate; e.ShipDate = c.ShipDate; e.TrackingNumber = c.TrackingNumber; e.DateReceived = c.DateReceived; e.IsInTransit = c.IsInTransit; e.IsApproved = c.IsApproved; e.IsInDispute = c.IsInDispute; e.RmaDocumentNumber = c.RmaDocumentNumber; e.ReversalDocumentNumber = c.ReversalDocumentNumber; e.Active = c.Active; e.CommandId = c.CommandId; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); var version = c.Version; foreach (ICreateInOutLine innerCommand in c.InOutLines) { ThrowOnInconsistentCommands(c, innerCommand); IInOutLineStateCreated innerEvent = MapCreate(innerCommand, c, version, _state); e.AddInOutLineEvent(innerEvent); } return(e); }
public virtual void Initialize(IInOutStateCreated stateCreated) { var aggregateId = stateCreated.InOutEventId.DocumentNumber; var state = new InOutState(); state.DocumentNumber = aggregateId; var aggregate = (InOutAggregate)GetInOutAggregate(state); var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId); aggregate.Apply(stateCreated); Persist(eventStoreAggregateId, aggregate, state); }
public virtual void When(IInOutStateCreated e) { ThrowOnWrongEvent(e); this.IsSOTransaction = (e.IsSOTransaction != null && e.IsSOTransaction.HasValue) ? e.IsSOTransaction.Value : default(bool); this.DocumentStatus = e.DocumentStatus; this.Posted = (e.Posted != null && e.Posted.HasValue) ? e.Posted.Value : default(bool); this.Processing = (e.Processing != null && e.Processing.HasValue) ? e.Processing.Value : default(bool); this.Processed = (e.Processed != null && e.Processed.HasValue) ? e.Processed.Value : default(bool); this.DocumentType = (e.DocumentType != null && e.DocumentType.HasValue) ? e.DocumentType.Value : default(int); this.Description = e.Description; this.OrderNumber = e.OrderNumber; this.DateOrdered = e.DateOrdered; this.IsPrinted = (e.IsPrinted != null && e.IsPrinted.HasValue) ? e.IsPrinted.Value : default(bool); this.MovementType = e.MovementType; this.MovementDate = e.MovementDate; this.BusinessPartnerId = e.BusinessPartnerId; this.WarehouseId = e.WarehouseId; this.POReference = e.POReference; this.FreightAmount = (e.FreightAmount != null && e.FreightAmount.HasValue) ? e.FreightAmount.Value : default(Money); this.ShipperId = e.ShipperId; this.ChargeAmount = (e.ChargeAmount != null && e.ChargeAmount.HasValue) ? e.ChargeAmount.Value : default(Money); this.DatePrinted = e.DatePrinted; this.SalesRepresentative = e.SalesRepresentative; this.NumberOfPackages = (e.NumberOfPackages != null && e.NumberOfPackages.HasValue) ? e.NumberOfPackages.Value : default(int); this.PickDate = e.PickDate; this.ShipDate = e.ShipDate; this.TrackingNumber = e.TrackingNumber; this.DateReceived = e.DateReceived; this.IsInTransit = (e.IsInTransit != null && e.IsInTransit.HasValue) ? e.IsInTransit.Value : default(bool); this.IsApproved = (e.IsApproved != null && e.IsApproved.HasValue) ? e.IsApproved.Value : default(bool); this.IsInDispute = (e.IsInDispute != null && e.IsInDispute.HasValue) ? e.IsInDispute.Value : default(bool); this.Volume = (e.Volume != null && e.Volume.HasValue) ? e.Volume.Value : default(decimal); this.Weight = (e.Weight != null && e.Weight.HasValue) ? e.Weight.Value : default(decimal); this.RmaNumber = e.RmaNumber; this.ReversalNumber = e.ReversalNumber; this.IsDropShip = (e.IsDropShip != null && e.IsDropShip.HasValue) ? e.IsDropShip.Value : default(bool); this.DropShipBusinessPartnerId = e.DropShipBusinessPartnerId; this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool); this.Deleted = false; this.CreatedBy = e.CreatedBy; this.CreatedAt = e.CreatedAt; foreach (IInOutLineStateCreated innerEvent in e.InOutLineEvents) { IInOutLineState innerState = this.InOutLines.Get(innerEvent.GlobalId.LineNumber, true); innerState.Mutate(innerEvent); } }
void IInOutState.When(IInOutStateCreated e) { throw new NotSupportedException(); }
public virtual void Create(ICreateInOut c) { IInOutStateCreated e = Map(c); Apply(e); }
protected void NewInOutDocumentActionCommandAndExecute(ICreateInOut c, IInOutState s, IInOutStateCreated e) { var pCommandHandler = this.InOutDocumentActionCommandHandler; var pCmdContent = c.DocumentAction; var pCmd = new PropertyCommand <DocumentAction, string> { Content = pCmdContent, GetState = () => s.DocumentStatus, SetState = p => e.DocumentStatus = p, OuterCommandType = CommandType.Create }; pCommandHandler.Execute(pCmd); }