/// <summary> /// api controller constructor /// </summary> /// <param name="_commands">Command object</param> /// <param name="_queries">Query object</param> /// <param name="_orderLogic">Order logic object</param> /// <param name="_mapper">Automapper</param> public ecomController(IOrderCommand _commands, IOrderQuery _queries, IOrderLogic _orderLogic, IMapper _mapper) { commandService = _commands; queryService = _queries; orderLogic = _orderLogic; mapper = _mapper; }
public async Task ExecuteCommandOnOrder(IOrderCommand orderCommand) { var sendToUri = new Uri($"{MassTransitConstant.RabbitMqUri}{MassTransitConstant.OrderSagaQueue}"); var endPoint = await _bus.GetSendEndpoint(sendToUri); await endPoint.Send(orderCommand, orderCommand.GetType()); }
public void placeIOrderCommands() { foreach (IOrderCommand IOrderCommand in IOrderCommandList) { IOrderCommand.execute(); } IOrderCommandList.Clear(); }
public void Setup() { fixture = new Fixture(); fixture.Behaviors.OfType <ThrowingRecursionBehavior>().ToList().ForEach(b => fixture.Behaviors.Remove(b)); fixture.Behaviors.Add(new OmitOnRecursionBehavior()); dbContext = new Mock <commandContext>(); command = new OrderCommand(dbContext.Object); }
public IOrderCommand CreateInstance(string[] args) { IOrderCommand cmd = null; var commandName = args[0]; List <IOrderFactory> allCommands = orderFactory; var cmdFactory = allCommands.FirstOrDefault(p => p.Name == commandName); cmd = cmdFactory.MakeInstance(args); return(cmd); }
}// END Map(IMergePatch... //////////////////////////// protected virtual IOrderRoleStateRemoved MapRemove(IRemoveOrderRole c, IOrderCommand outerCommand, long version) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new OrderRoleEventId(c.OrderId, c.PartyRoleId, version); IOrderRoleStateRemoved e = NewOrderRoleStateRemoved(stateEventId); e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); return(e); }// END Map(IRemove... ////////////////////////////
protected virtual IOrderRoleStateCreated MapCreate(ICreateOrderRole c, IOrderCommand outerCommand, long version, IOrderState outerState) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new OrderRoleEventId(c.OrderId, c.PartyRoleId, version); IOrderRoleStateCreated e = NewOrderRoleStateCreated(stateEventId); var s = outerState.OrderRoles.Get(c.PartyRoleId, true); e.Active = c.Active; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); return(e); }// END Map(ICreate... ////////////////////////////
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); }
protected virtual IOrderItemStateCreated MapCreate(ICreateOrderItem c, IOrderCommand outerCommand, long version, IOrderState outerState) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new OrderItemEventId(c.OrderId, c.OrderItemSeqId, version); IOrderItemStateCreated e = NewOrderItemStateCreated(stateEventId); var s = outerState.OrderItems.Get(c.OrderItemSeqId, true); 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.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); return(e); }// END Map(ICreate... ////////////////////////////
}// END Map(IRemove... //////////////////////////// protected virtual IOrderItemEvent Map(IOrderItemCommand c, IOrderCommand outerCommand, long version, IOrderState outerState) { var create = (c.CommandType == CommandType.Create) ? (c as ICreateOrderItem) : null; if (create != null) { return(MapCreate(create, outerCommand, version, outerState)); } var merge = (c.CommandType == CommandType.MergePatch || c.CommandType == null) ? (c as IMergePatchOrderItem) : null; if (merge != null) { return(MapMergePatch(merge, outerCommand, version, outerState)); } throw new NotSupportedException(); }
protected virtual void Update(IOrderCommand c, Action <IOrderAggregate> action) { var aggregateId = c.AggregateId; var state = StateRepository.Get(aggregateId, false); var aggregate = GetOrderAggregate(state); var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId); var repeated = IsRepeatedCommand(c, eventStoreAggregateId, state); if (repeated) { return; } aggregate.ThrowOnInvalidStateTransition(c); action(aggregate); Persist(eventStoreAggregateId, aggregate, state); }
}// END ThrowOnInconsistentCommands ///////////////////// protected void ThrowOnInconsistentCommands(IOrderCommand command, IOrderShipGroupCommand innerCommand) { var properties = command as ICreateOrMergePatchOrDeleteOrder; var innerProperties = innerCommand as ICreateOrMergePatchOrRemoveOrderShipGroup; if (properties == null || innerProperties == null) { return; } if (innerProperties.OrderId == default(string)) { innerProperties.OrderId = properties.OrderId; } else { var outerOrderIdName = "OrderId"; var outerOrderIdValue = properties.OrderId; var innerOrderIdName = "OrderId"; var innerOrderIdValue = innerProperties.OrderId; ThrowOnInconsistentIds(innerProperties, innerOrderIdName, innerOrderIdValue, outerOrderIdName, outerOrderIdValue); } }// END ThrowOnInconsistentCommands /////////////////////
public void TakeOrder(IOrderCommand command) { _orderCommands.Add(command); }
public OrderController(IOrderCommand command, ILineItemCommand lineItemCommand, IOrderSubmitCommand orderSubmitCommand) { _command = command; _lineItemCommand = lineItemCommand; _orderSubmitCommand = orderSubmitCommand; }
public MessageSendersController(ISendgridService sendgridService, IOrderCommand orderCommand) { _sendgridService = sendgridService; _orderCommand = orderCommand; }
public OrderController(IOrderCommand command, ILineItemCommand lineItemCommand, AppSettings settings, IOrderSubmitCommand orderSubmitCommand) : base(settings) { _command = command; _lineItemCommand = lineItemCommand; _orderSubmitCommand = orderSubmitCommand; }
public void TakeOrder(IOrderCommand order) { _orders.Add(order); }
public OrderInvoker(Customer customer) { this.command = new OrderCommand(customer); }
}// 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 OrderController(IOrderCommand command, IOrderQuery query) { _command = command; _query = query; }
public void takeIOrderCommand(IOrderCommand IOrderCommand) { IOrderCommandList.Add(IOrderCommand); }
public void ExecuteCommand(IOrderCommand command, MenuItem item) { command.Execute(Orders, item); }
public void RemoveOrder(IOrderCommand command) { _orderCommands.Remove(command); }
public void PlaceOrder(IOrderCommand order) { OrderList.Add(order); }
internal void Invoke(IOrderCommand cmd) { cmd.Execute(); commandsStack.Push(cmd); }
public void TakeOrder(IOrderCommand order) => customerOrders.Add(order);
private static bool IsCommandCreate(IOrderCommand c) { return(c.Version == OrderState.VersionZero); }
public void TakeOrder(IOrderCommand order) { OrderList.Add(order); }
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... ////////////////////////////