protected virtual IMovementConfirmationStateMergePatched Map(IMergePatchMovementConfirmation c) { var stateEventId = new MovementConfirmationEventId(c.DocumentNumber, c.Version); IMovementConfirmationStateMergePatched e = NewMovementConfirmationStateMergePatched(stateEventId); e.MovementDocumentNumber = c.MovementDocumentNumber; e.IsApproved = c.IsApproved; e.ApprovalAmount = c.ApprovalAmount; e.Processed = c.Processed; e.Processing = c.Processing; e.DocumentTypeId = c.DocumentTypeId; e.Description = c.Description; e.Active = c.Active; e.IsPropertyMovementDocumentNumberRemoved = c.IsPropertyMovementDocumentNumberRemoved; e.IsPropertyIsApprovedRemoved = c.IsPropertyIsApprovedRemoved; e.IsPropertyApprovalAmountRemoved = c.IsPropertyApprovalAmountRemoved; e.IsPropertyProcessedRemoved = c.IsPropertyProcessedRemoved; e.IsPropertyProcessingRemoved = c.IsPropertyProcessingRemoved; e.IsPropertyDocumentTypeIdRemoved = c.IsPropertyDocumentTypeIdRemoved; e.IsPropertyDescriptionRemoved = c.IsPropertyDescriptionRemoved; e.IsPropertyActiveRemoved = c.IsPropertyActiveRemoved; e.CommandId = c.CommandId; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); var version = c.Version; foreach (IMovementConfirmationLineCommand innerCommand in c.MovementConfirmationLineCommands) { ThrowOnInconsistentCommands(c, innerCommand); IMovementConfirmationLineEvent innerEvent = Map(innerCommand, c, version, _state); e.AddMovementConfirmationLineEvent(innerEvent); } return(e); }
public virtual MovementConfirmationStateMergePatchedDto ToMovementConfirmationStateMergePatchedDto(IMovementConfirmationStateMergePatched e) { var dto = new MovementConfirmationStateMergePatchedDto(); dto.MovementConfirmationEventId = e.MovementConfirmationEventId; dto.CreatedAt = e.CreatedAt; dto.CreatedBy = e.CreatedBy; dto.CommandId = e.CommandId; dto.DocumentStatusId = e.DocumentStatusId; dto.MovementDocumentNumber = e.MovementDocumentNumber; dto.IsApproved = e.IsApproved; dto.ApprovalAmount = e.ApprovalAmount; dto.Processed = e.Processed; dto.Processing = e.Processing; dto.DocumentTypeId = e.DocumentTypeId; dto.Description = e.Description; dto.Active = e.Active; dto.IsPropertyDocumentStatusIdRemoved = e.IsPropertyDocumentStatusIdRemoved; dto.IsPropertyMovementDocumentNumberRemoved = e.IsPropertyMovementDocumentNumberRemoved; dto.IsPropertyIsApprovedRemoved = e.IsPropertyIsApprovedRemoved; dto.IsPropertyApprovalAmountRemoved = e.IsPropertyApprovalAmountRemoved; dto.IsPropertyProcessedRemoved = e.IsPropertyProcessedRemoved; dto.IsPropertyProcessingRemoved = e.IsPropertyProcessingRemoved; dto.IsPropertyDocumentTypeIdRemoved = e.IsPropertyDocumentTypeIdRemoved; dto.IsPropertyDescriptionRemoved = e.IsPropertyDescriptionRemoved; dto.IsPropertyActiveRemoved = e.IsPropertyActiveRemoved; var movementConfirmationLineEvents = new List <MovementConfirmationLineStateCreatedOrMergePatchedOrRemovedDto>(); foreach (var ee in e.MovementConfirmationLineEvents) { MovementConfirmationLineStateCreatedOrMergePatchedOrRemovedDto eeDto = MovementConfirmationLineStateEventDtoConverter.ToMovementConfirmationLineStateEventDto(ee); movementConfirmationLineEvents.Add(eeDto); } dto.MovementConfirmationLineEvents = movementConfirmationLineEvents.ToArray(); return(dto); }
void IMovementConfirmationState.When(IMovementConfirmationStateMergePatched e) { throw new NotSupportedException(); }
public virtual void MergePatch(IMergePatchMovementConfirmation c) { IMovementConfirmationStateMergePatched e = Map(c); Apply(e); }
public virtual void When(IMovementConfirmationStateMergePatched e) { ThrowOnWrongEvent(e); if (e.DocumentStatusId == null) { if (e.IsPropertyDocumentStatusIdRemoved) { this.DocumentStatusId = default(string); } } else { this.DocumentStatusId = e.DocumentStatusId; } if (e.MovementDocumentNumber == null) { if (e.IsPropertyMovementDocumentNumberRemoved) { this.MovementDocumentNumber = default(string); } } else { this.MovementDocumentNumber = e.MovementDocumentNumber; } if (e.IsApproved == null) { if (e.IsPropertyIsApprovedRemoved) { this.IsApproved = default(bool); } } else { this.IsApproved = (e.IsApproved != null && e.IsApproved.HasValue) ? e.IsApproved.Value : default(bool); } if (e.ApprovalAmount == null) { if (e.IsPropertyApprovalAmountRemoved) { this.ApprovalAmount = default(decimal); } } else { this.ApprovalAmount = (e.ApprovalAmount != null && e.ApprovalAmount.HasValue) ? e.ApprovalAmount.Value : default(decimal); } if (e.Processed == null) { if (e.IsPropertyProcessedRemoved) { this.Processed = default(bool); } } else { this.Processed = (e.Processed != null && e.Processed.HasValue) ? e.Processed.Value : default(bool); } if (e.Processing == null) { if (e.IsPropertyProcessingRemoved) { this.Processing = default(string); } } else { this.Processing = e.Processing; } if (e.DocumentTypeId == null) { if (e.IsPropertyDocumentTypeIdRemoved) { this.DocumentTypeId = default(string); } } else { this.DocumentTypeId = e.DocumentTypeId; } if (e.Description == null) { if (e.IsPropertyDescriptionRemoved) { this.Description = default(string); } } else { this.Description = e.Description; } if (e.Active == null) { if (e.IsPropertyActiveRemoved) { this.Active = default(bool); } } else { this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool); } this.UpdatedBy = e.CreatedBy; this.UpdatedAt = e.CreatedAt; foreach (IMovementConfirmationLineEvent innerEvent in e.MovementConfirmationLineEvents) { IMovementConfirmationLineState innerState = this.MovementConfirmationLines.Get(innerEvent.GlobalId.LineNumber); innerState.Mutate(innerEvent); var removed = innerEvent as IMovementConfirmationLineStateRemoved; if (removed != null) { this.MovementConfirmationLines.Remove(innerState); } } }