protected virtual void AddProductToState(Product product, IOrderState orderState) { var products = new List<Product>(orderState.Products); products.Add(product); orderState.Products = products; }
// we should use event based for this internal void MagicBoxCompleted() { // should create default state expiracyTimer.Finish(); expiracyTimer.Expired -= expiracyTimer_Expired; state = null; OnOrderClosed(); }
public Order(IOrderState orderState) { _orderState = orderState; }
}// END Map(ICreate... //////////////////////////// protected virtual IOrderShipGroupStateMergePatched MapMergePatch(IMergePatchOrderShipGroup c, IOrderCommand outerCommand, long version, IOrderState outerState) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new OrderShipGroupEventId(c.OrderId, c.ShipGroupSeqId, version); IOrderShipGroupStateMergePatched e = NewOrderShipGroupStateMergePatched(stateEventId); var s = outerState.OrderShipGroups.Get(c.ShipGroupSeqId); e.ShipmentMethodTypeId = c.ShipmentMethodTypeId; e.SupplierPartyId = c.SupplierPartyId; e.VendorPartyId = c.VendorPartyId; e.CarrierPartyId = c.CarrierPartyId; e.CarrierRoleTypeId = c.CarrierRoleTypeId; e.FacilityId = c.FacilityId; e.DestinationFacilityId = c.DestinationFacilityId; e.ContactMechId = c.ContactMechId; e.TelecomContactMechId = c.TelecomContactMechId; e.TrackingNumber = c.TrackingNumber; e.ContactPartyId = c.ContactPartyId; e.VehiclePlateNumber = c.VehiclePlateNumber; e.ShippingInstructions = c.ShippingInstructions; e.MaySplit = c.MaySplit; e.GiftMessage = c.GiftMessage; e.IsGift = c.IsGift; e.ShipAfterDate = c.ShipAfterDate; e.ShipByDate = c.ShipByDate; e.EstimatedShipDate = c.EstimatedShipDate; e.EstimatedDeliveryDate = c.EstimatedDeliveryDate; e.PickwaveId = c.PickwaveId; e.NumberOfPackages = c.NumberOfPackages; e.NumberOfContainers = c.NumberOfContainers; e.NumberOfPakagesPerContainer = c.NumberOfPakagesPerContainer; e.Active = c.Active; e.IsPropertyShipmentMethodTypeIdRemoved = c.IsPropertyShipmentMethodTypeIdRemoved; e.IsPropertySupplierPartyIdRemoved = c.IsPropertySupplierPartyIdRemoved; e.IsPropertyVendorPartyIdRemoved = c.IsPropertyVendorPartyIdRemoved; e.IsPropertyCarrierPartyIdRemoved = c.IsPropertyCarrierPartyIdRemoved; e.IsPropertyCarrierRoleTypeIdRemoved = c.IsPropertyCarrierRoleTypeIdRemoved; e.IsPropertyFacilityIdRemoved = c.IsPropertyFacilityIdRemoved; e.IsPropertyDestinationFacilityIdRemoved = c.IsPropertyDestinationFacilityIdRemoved; e.IsPropertyContactMechIdRemoved = c.IsPropertyContactMechIdRemoved; e.IsPropertyTelecomContactMechIdRemoved = c.IsPropertyTelecomContactMechIdRemoved; e.IsPropertyTrackingNumberRemoved = c.IsPropertyTrackingNumberRemoved; e.IsPropertyContactPartyIdRemoved = c.IsPropertyContactPartyIdRemoved; e.IsPropertyVehiclePlateNumberRemoved = c.IsPropertyVehiclePlateNumberRemoved; e.IsPropertyShippingInstructionsRemoved = c.IsPropertyShippingInstructionsRemoved; e.IsPropertyMaySplitRemoved = c.IsPropertyMaySplitRemoved; e.IsPropertyGiftMessageRemoved = c.IsPropertyGiftMessageRemoved; e.IsPropertyIsGiftRemoved = c.IsPropertyIsGiftRemoved; e.IsPropertyShipAfterDateRemoved = c.IsPropertyShipAfterDateRemoved; e.IsPropertyShipByDateRemoved = c.IsPropertyShipByDateRemoved; e.IsPropertyEstimatedShipDateRemoved = c.IsPropertyEstimatedShipDateRemoved; e.IsPropertyEstimatedDeliveryDateRemoved = c.IsPropertyEstimatedDeliveryDateRemoved; e.IsPropertyPickwaveIdRemoved = c.IsPropertyPickwaveIdRemoved; e.IsPropertyNumberOfPackagesRemoved = c.IsPropertyNumberOfPackagesRemoved; e.IsPropertyNumberOfContainersRemoved = c.IsPropertyNumberOfContainersRemoved; e.IsPropertyNumberOfPakagesPerContainerRemoved = c.IsPropertyNumberOfPakagesPerContainerRemoved; e.IsPropertyActiveRemoved = c.IsPropertyActiveRemoved; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); foreach (IOrderItemShipGroupAssociationCommand innerCommand in c.OrderItemShipGroupAssociationCommands) { ThrowOnInconsistentCommands(c, innerCommand); IOrderItemShipGroupAssociationEvent innerEvent = Map(innerCommand, c, version, s); e.AddOrderItemShipGroupAssociationEvent(innerEvent); } return(e); }// END Map(IMergePatch... ////////////////////////////
public void SetState(IOrderState s) { _current = s; }
}// END Map(ICreate... //////////////////////////// protected virtual IOrderRoleStateMergePatched MapMergePatch(IMergePatchOrderRole c, IOrderCommand outerCommand, long version, IOrderState outerState) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new OrderRoleEventId(c.OrderId, c.PartyRoleId, version); IOrderRoleStateMergePatched e = NewOrderRoleStateMergePatched(stateEventId); var s = outerState.OrderRoles.Get(c.PartyRoleId); e.Active = c.Active; e.IsPropertyActiveRemoved = c.IsPropertyActiveRemoved; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); return(e); }// END Map(IMergePatch... ////////////////////////////
}// END Map(ICreate... //////////////////////////// protected virtual IOrderItemStateMergePatched MapMergePatch(IMergePatchOrderItem c, IOrderCommand outerCommand, long version, IOrderState outerState) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new OrderItemEventId(c.OrderId, c.OrderItemSeqId, version); IOrderItemStateMergePatched e = NewOrderItemStateMergePatched(stateEventId); var s = outerState.OrderItems.Get(c.OrderItemSeqId); e.ProductId = c.ProductId; e.ExternalProductId = c.ExternalProductId; e.Quantity = c.Quantity; e.CancelQuantity = c.CancelQuantity; e.SelectedAmount = c.SelectedAmount; e.ExternalId = c.ExternalId; e.OrderItemTypeId = c.OrderItemTypeId; e.OrderItemGroupSeqId = c.OrderItemGroupSeqId; e.IsItemGroupPrimary = c.IsItemGroupPrimary; e.FromInventoryItemId = c.FromInventoryItemId; e.IsPromo = c.IsPromo; e.QuoteId = c.QuoteId; e.QuoteItemSeqId = c.QuoteItemSeqId; e.ShoppingListId = c.ShoppingListId; e.ShoppingListItemSeqId = c.ShoppingListItemSeqId; e.UnitPrice = c.UnitPrice; e.UnitListPrice = c.UnitListPrice; e.UnitAverageCost = c.UnitAverageCost; e.UnitRecurringPrice = c.UnitRecurringPrice; e.IsModifiedPrice = c.IsModifiedPrice; e.RecurringFreqUomId = c.RecurringFreqUomId; e.ItemDescription = c.ItemDescription; e.Comments = c.Comments; e.CorrespondingPoId = c.CorrespondingPoId; e.StatusId = c.StatusId; e.SyncStatusId = c.SyncStatusId; e.EstimatedShipDate = c.EstimatedShipDate; e.EstimatedDeliveryDate = c.EstimatedDeliveryDate; e.AutoCancelDate = c.AutoCancelDate; e.DontCancelSetDate = c.DontCancelSetDate; e.DontCancelSetBy = c.DontCancelSetBy; e.ShipBeforeDate = c.ShipBeforeDate; e.ShipAfterDate = c.ShipAfterDate; e.CancelBackOrderDate = c.CancelBackOrderDate; e.OverrideGlAccountId = c.OverrideGlAccountId; e.Active = c.Active; e.IsPropertyProductIdRemoved = c.IsPropertyProductIdRemoved; e.IsPropertyExternalProductIdRemoved = c.IsPropertyExternalProductIdRemoved; e.IsPropertyQuantityRemoved = c.IsPropertyQuantityRemoved; e.IsPropertyCancelQuantityRemoved = c.IsPropertyCancelQuantityRemoved; e.IsPropertySelectedAmountRemoved = c.IsPropertySelectedAmountRemoved; e.IsPropertyExternalIdRemoved = c.IsPropertyExternalIdRemoved; e.IsPropertyOrderItemTypeIdRemoved = c.IsPropertyOrderItemTypeIdRemoved; e.IsPropertyOrderItemGroupSeqIdRemoved = c.IsPropertyOrderItemGroupSeqIdRemoved; e.IsPropertyIsItemGroupPrimaryRemoved = c.IsPropertyIsItemGroupPrimaryRemoved; e.IsPropertyFromInventoryItemIdRemoved = c.IsPropertyFromInventoryItemIdRemoved; e.IsPropertyIsPromoRemoved = c.IsPropertyIsPromoRemoved; e.IsPropertyQuoteIdRemoved = c.IsPropertyQuoteIdRemoved; e.IsPropertyQuoteItemSeqIdRemoved = c.IsPropertyQuoteItemSeqIdRemoved; e.IsPropertyShoppingListIdRemoved = c.IsPropertyShoppingListIdRemoved; e.IsPropertyShoppingListItemSeqIdRemoved = c.IsPropertyShoppingListItemSeqIdRemoved; e.IsPropertyUnitPriceRemoved = c.IsPropertyUnitPriceRemoved; e.IsPropertyUnitListPriceRemoved = c.IsPropertyUnitListPriceRemoved; e.IsPropertyUnitAverageCostRemoved = c.IsPropertyUnitAverageCostRemoved; e.IsPropertyUnitRecurringPriceRemoved = c.IsPropertyUnitRecurringPriceRemoved; e.IsPropertyIsModifiedPriceRemoved = c.IsPropertyIsModifiedPriceRemoved; e.IsPropertyRecurringFreqUomIdRemoved = c.IsPropertyRecurringFreqUomIdRemoved; e.IsPropertyItemDescriptionRemoved = c.IsPropertyItemDescriptionRemoved; e.IsPropertyCommentsRemoved = c.IsPropertyCommentsRemoved; e.IsPropertyCorrespondingPoIdRemoved = c.IsPropertyCorrespondingPoIdRemoved; e.IsPropertyStatusIdRemoved = c.IsPropertyStatusIdRemoved; e.IsPropertySyncStatusIdRemoved = c.IsPropertySyncStatusIdRemoved; e.IsPropertyEstimatedShipDateRemoved = c.IsPropertyEstimatedShipDateRemoved; e.IsPropertyEstimatedDeliveryDateRemoved = c.IsPropertyEstimatedDeliveryDateRemoved; e.IsPropertyAutoCancelDateRemoved = c.IsPropertyAutoCancelDateRemoved; e.IsPropertyDontCancelSetDateRemoved = c.IsPropertyDontCancelSetDateRemoved; e.IsPropertyDontCancelSetByRemoved = c.IsPropertyDontCancelSetByRemoved; e.IsPropertyShipBeforeDateRemoved = c.IsPropertyShipBeforeDateRemoved; e.IsPropertyShipAfterDateRemoved = c.IsPropertyShipAfterDateRemoved; e.IsPropertyCancelBackOrderDateRemoved = c.IsPropertyCancelBackOrderDateRemoved; e.IsPropertyOverrideGlAccountIdRemoved = c.IsPropertyOverrideGlAccountIdRemoved; e.IsPropertyActiveRemoved = c.IsPropertyActiveRemoved; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); return(e); }// END Map(IMergePatch... ////////////////////////////
// we should use event based for this internal void OrderRunning(Order order, ITrailingMethod trailing) { ResetExpiracy(); state = new OrderAlreadyRunning(this, order, trailing); }
private void Change(IOrderState orderState) { _orderState = orderState; }
internal void SetStateTo(IOrderState state) { this._state = state; }
private void Persist(IEventStoreAggregateId eventStoreAggregateId, IOrderAggregate aggregate, IOrderState state) { EventStore.AppendEvents(eventStoreAggregateId, ((IOrderStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); }); if (AggregateEventListener != null) { AggregateEventListener.EventAppended(new AggregateEvent <IOrderAggregate, IOrderState>(aggregate, state, aggregate.Changes)); } }
public OrderStateDtoWrapper() { this._state = new OrderState(); }
public OrderStateDtoWrapper(IOrderState state) { this._state = state; }
public static TMergePatchOrder ToMergePatchOrder <TMergePatchOrder, TCreateOrderRole, TMergePatchOrderRole, TCreateOrderItem, TMergePatchOrderItem, TCreateOrderShipGroup, TMergePatchOrderShipGroup, TCreateOrderItemShipGroupAssociation, TMergePatchOrderItemShipGroupAssociation>(this IOrderState state) where TMergePatchOrder : IMergePatchOrder, new() where TCreateOrderRole : ICreateOrderRole, new() where TMergePatchOrderRole : IMergePatchOrderRole, new() where TCreateOrderItem : ICreateOrderItem, new() where TMergePatchOrderItem : IMergePatchOrderItem, new() where TCreateOrderShipGroup : ICreateOrderShipGroup, new() where TMergePatchOrderShipGroup : IMergePatchOrderShipGroup, new() where TCreateOrderItemShipGroupAssociation : ICreateOrderItemShipGroupAssociation, new() where TMergePatchOrderItemShipGroupAssociation : IMergePatchOrderItemShipGroupAssociation, new() { var cmd = new TMergePatchOrder(); cmd.Version = ((IOrderStateProperties)state).Version; cmd.OrderId = state.OrderId; cmd.OrderTypeId = state.OrderTypeId; cmd.OrderName = state.OrderName; cmd.ExternalId = state.ExternalId; cmd.SalesChannelEnumId = state.SalesChannelEnumId; cmd.OrderDate = state.OrderDate; cmd.Priority = state.Priority; cmd.EntryDate = state.EntryDate; cmd.PickSheetPrintedDate = state.PickSheetPrintedDate; cmd.StatusId = state.StatusId; cmd.CurrencyUom = state.CurrencyUom; cmd.SyncStatusId = state.SyncStatusId; cmd.BillingAccountId = state.BillingAccountId; cmd.OriginFacilityId = state.OriginFacilityId; cmd.WebSiteId = state.WebSiteId; cmd.ProductStoreId = state.ProductStoreId; cmd.TerminalId = state.TerminalId; cmd.TransactionId = state.TransactionId; cmd.AutoOrderShoppingListId = state.AutoOrderShoppingListId; cmd.NeedsInventoryIssuance = state.NeedsInventoryIssuance; cmd.IsRushOrder = state.IsRushOrder; cmd.InternalCode = state.InternalCode; cmd.RemainingSubTotal = state.RemainingSubTotal; cmd.GrandTotal = state.GrandTotal; cmd.InvoicePerShipment = state.InvoicePerShipment; cmd.Active = ((IOrderStateProperties)state).Active; if (state.OrderTypeId == null) { cmd.IsPropertyOrderTypeIdRemoved = true; } if (state.OrderName == null) { cmd.IsPropertyOrderNameRemoved = true; } if (state.ExternalId == null) { cmd.IsPropertyExternalIdRemoved = true; } if (state.SalesChannelEnumId == null) { cmd.IsPropertySalesChannelEnumIdRemoved = true; } if (state.OrderDate == null) { cmd.IsPropertyOrderDateRemoved = true; } if (state.Priority == null) { cmd.IsPropertyPriorityRemoved = true; } if (state.EntryDate == null) { cmd.IsPropertyEntryDateRemoved = true; } if (state.PickSheetPrintedDate == null) { cmd.IsPropertyPickSheetPrintedDateRemoved = true; } if (state.StatusId == null) { cmd.IsPropertyStatusIdRemoved = true; } if (state.CurrencyUom == null) { cmd.IsPropertyCurrencyUomRemoved = true; } if (state.SyncStatusId == null) { cmd.IsPropertySyncStatusIdRemoved = true; } if (state.BillingAccountId == null) { cmd.IsPropertyBillingAccountIdRemoved = true; } if (state.OriginFacilityId == null) { cmd.IsPropertyOriginFacilityIdRemoved = true; } if (state.WebSiteId == null) { cmd.IsPropertyWebSiteIdRemoved = true; } if (state.ProductStoreId == null) { cmd.IsPropertyProductStoreIdRemoved = true; } if (state.TerminalId == null) { cmd.IsPropertyTerminalIdRemoved = true; } if (state.TransactionId == null) { cmd.IsPropertyTransactionIdRemoved = true; } if (state.AutoOrderShoppingListId == null) { cmd.IsPropertyAutoOrderShoppingListIdRemoved = true; } if (state.NeedsInventoryIssuance == null) { cmd.IsPropertyNeedsInventoryIssuanceRemoved = true; } if (state.IsRushOrder == null) { cmd.IsPropertyIsRushOrderRemoved = true; } if (state.InternalCode == null) { cmd.IsPropertyInternalCodeRemoved = true; } if (state.RemainingSubTotal == null) { cmd.IsPropertyRemainingSubTotalRemoved = true; } if (state.GrandTotal == null) { cmd.IsPropertyGrandTotalRemoved = true; } if (state.InvoicePerShipment == null) { cmd.IsPropertyInvoicePerShipmentRemoved = true; } foreach (var d in state.OrderRoles) { var c = d.ToCreateOrMergePatchOrderRole <TCreateOrderRole, TMergePatchOrderRole>(); cmd.OrderRoleCommands.Add(c); } foreach (var d in state.OrderItems) { var c = d.ToCreateOrMergePatchOrderItem <TCreateOrderItem, TMergePatchOrderItem>(); cmd.OrderItemCommands.Add(c); } foreach (var d in state.OrderShipGroups) { var c = d.ToCreateOrMergePatchOrderShipGroup <TCreateOrderShipGroup, TMergePatchOrderShipGroup, TCreateOrderItemShipGroupAssociation, TMergePatchOrderItemShipGroupAssociation>(); cmd.OrderShipGroupCommands.Add(c); } return(cmd); }
public static IOrderCommand ToCreateOrMergePatchOrder <TCreateOrder, TMergePatchOrder, TCreateOrderRole, TMergePatchOrderRole, TCreateOrderItem, TMergePatchOrderItem, TCreateOrderShipGroup, TMergePatchOrderShipGroup, TCreateOrderItemShipGroupAssociation, TMergePatchOrderItemShipGroupAssociation>(this IOrderState state) where TCreateOrder : ICreateOrder, new() where TMergePatchOrder : IMergePatchOrder, new() where TCreateOrderRole : ICreateOrderRole, new() where TMergePatchOrderRole : IMergePatchOrderRole, new() where TCreateOrderItem : ICreateOrderItem, new() where TMergePatchOrderItem : IMergePatchOrderItem, new() where TCreateOrderShipGroup : ICreateOrderShipGroup, new() where TMergePatchOrderShipGroup : IMergePatchOrderShipGroup, new() where TCreateOrderItemShipGroupAssociation : ICreateOrderItemShipGroupAssociation, new() where TMergePatchOrderItemShipGroupAssociation : IMergePatchOrderItemShipGroupAssociation, new() { bool bUnsaved = ((IOrderState)state).IsUnsaved; if (bUnsaved) { return(state.ToCreateOrder <TCreateOrder, TCreateOrderRole, TCreateOrderItem, TCreateOrderShipGroup, TCreateOrderItemShipGroupAssociation>()); } else { return(state.ToMergePatchOrder <TMergePatchOrder, TCreateOrderRole, TMergePatchOrderRole, TCreateOrderItem, TMergePatchOrderItem, TCreateOrderShipGroup, TMergePatchOrderShipGroup, TCreateOrderItemShipGroupAssociation, TMergePatchOrderItemShipGroupAssociation>()); } }
// we should use event based for this internal void OrderRunning(Order order, IProfitProtector trailing) { ResetExpiracy(); state = new OrderAlreadyRunning(this, order, trailing); }
internal void Change(IOrderState orderState) { _orderState = orderState; }
public void ChangeState(IOrderState newState) { State = newState; Console.WriteLine("order state changed to {0}", State.GetType().Name); }
public OrderState() { _CurrentState = new NewOrder(this); }
// 設定下一關卡的狀態 public void setState(IOrderState state) { current_state = state; }
protected virtual IOrderShipGroupStateCreated MapCreate(ICreateOrderShipGroup c, IOrderCommand outerCommand, long version, IOrderState outerState) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new OrderShipGroupEventId(c.OrderId, c.ShipGroupSeqId, version); IOrderShipGroupStateCreated e = NewOrderShipGroupStateCreated(stateEventId); var s = outerState.OrderShipGroups.Get(c.ShipGroupSeqId, true); e.ShipmentMethodTypeId = c.ShipmentMethodTypeId; e.SupplierPartyId = c.SupplierPartyId; e.VendorPartyId = c.VendorPartyId; e.CarrierPartyId = c.CarrierPartyId; e.CarrierRoleTypeId = c.CarrierRoleTypeId; e.FacilityId = c.FacilityId; e.ContactMechId = c.ContactMechId; e.TelecomContactMechId = c.TelecomContactMechId; e.TrackingNumber = c.TrackingNumber; e.ShippingInstructions = c.ShippingInstructions; e.MaySplit = c.MaySplit; e.GiftMessage = c.GiftMessage; e.IsGift = c.IsGift; e.ShipAfterDate = c.ShipAfterDate; e.ShipByDate = c.ShipByDate; e.EstimatedShipDate = c.EstimatedShipDate; e.EstimatedDeliveryDate = c.EstimatedDeliveryDate; e.PickwaveId = c.PickwaveId; e.Active = c.Active; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); foreach (ICreateOrderItemShipGroupAssociation innerCommand in c.OrderItemShipGroupAssociations) { ThrowOnInconsistentCommands(c, innerCommand); IOrderItemShipGroupAssociationStateCreated innerEvent = MapCreate(innerCommand, c, version, s); e.AddOrderItemShipGroupAssociationEvent(innerEvent); } return(e); }// END Map(ICreate... ////////////////////////////
private void AddOneCancelAnother(Order buyOrder, Order sellOrder) { state = new MagicBoxCreated(this, buyOrder, sellOrder, mbConfig); }
public Order() { _orderState = new NewState(); }
public OrderContext(IOrderState orderState) { _orderState = orderState; }
public void Change(IOrderState state) { _orderState = state; }
public OrderAggregate(IOrderState state) { _state = state; }
public Order(IOrderState orderState) { this._orderState = orderState; }
}// END Map(IMergePatch... //////////////////////////// protected virtual IOrderShipGroupEvent Map(IOrderShipGroupCommand c, IOrderCommand outerCommand, long version, IOrderState outerState) { var create = (c.CommandType == CommandType.Create) ? (c as ICreateOrderShipGroup) : null; if (create != null) { return(MapCreate(create, outerCommand, version, outerState)); } var merge = (c.CommandType == CommandType.MergePatch || c.CommandType == null) ? (c as IMergePatchOrderShipGroup) : null; if (merge != null) { return(MapMergePatch(merge, outerCommand, version, outerState)); } var remove = (c.CommandType == CommandType.Remove) ? (c as IRemoveOrderShipGroup) : null; if (remove != null) { return(MapRemove(remove, outerCommand, version)); } throw new NotSupportedException(); }
public void Change(IOrderState orderState) { this._orderState = orderState; }
public OrderShipGroupStates(IOrderState outerState) { this._orderState = outerState; this._forReapplying = outerState.ForReapplying; }
public OrderItemStates(IOrderState outerState) { this._orderState = outerState; this._forReapplying = outerState.ForReapplying; }
public Order() { _current = new WaitForAcceptance(); IsCancel = false; }
internal void SetStateTo(IOrderState state) { this._orderState = state; this.Status = this._orderState.Status; }
public void AddProductsToOrder(IEnumerable<Product> products, IOrderState orderState) { foreach (var product in products) AddProductToState(product, orderState); }
public Order(IOrderState baseState) { _orderState = baseState; }
public Order() { _created = DateTime.Now; _items = new List <OrderItem>(); _state = OrderStates.Open; }
/// <summary> /// Order类的核心是这个方法,通过这个方法实现根据传入的某接口的 实现类来改变当前类中的实现类的方式!! /// </summary> /// <param name="OrderState"></param> internal void Change(IOrderState OrderState) { _orderState = OrderState; }
public abstract IOrderAggregate GetOrderAggregate(IOrderState state);
public void ChangeState(Order order, IOrderState newState) { order.ChangeState(newState); }
protected bool IsRepeatedCommand(IOrderCommand command, IEventStoreAggregateId eventStoreAggregateId, IOrderState state) { bool repeated = false; if (((IOrderStateProperties)state).Version > command.AggregateVersion) { var lastEvent = EventStore.GetEvent(typeof(IOrderEvent), eventStoreAggregateId, command.AggregateVersion); if (lastEvent != null && lastEvent.CommandId == command.CommandId) { repeated = true; } } return(repeated); }
// constructor public OrderStateContext() { current_state = new NewOrderState(); // 訂單建立時的初始狀態為 'NEW_ORDER' }