Пример #1
0
 /// <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;
 }
Пример #2
0
        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());
        }
Пример #3
0
 public void placeIOrderCommands()
 {
     foreach (IOrderCommand IOrderCommand in IOrderCommandList)
     {
         IOrderCommand.execute();
     }
     IOrderCommandList.Clear();
 }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        }// 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... ////////////////////////////
Пример #7
0
        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... ////////////////////////////
Пример #8
0
        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);
        }
Пример #9
0
        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... ////////////////////////////
Пример #10
0
        }// 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();
        }
Пример #11
0
        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);
        }
Пример #12
0
        }// 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 /////////////////////
Пример #13
0
 public void TakeOrder(IOrderCommand command)
 {
     _orderCommands.Add(command);
 }
Пример #14
0
 public OrderController(IOrderCommand command, ILineItemCommand lineItemCommand, IOrderSubmitCommand orderSubmitCommand)
 {
     _command            = command;
     _lineItemCommand    = lineItemCommand;
     _orderSubmitCommand = orderSubmitCommand;
 }
 public MessageSendersController(ISendgridService sendgridService, IOrderCommand orderCommand)
 {
     _sendgridService = sendgridService;
     _orderCommand    = orderCommand;
 }
Пример #16
0
 public OrderController(IOrderCommand command, ILineItemCommand lineItemCommand, AppSettings settings, IOrderSubmitCommand orderSubmitCommand) : base(settings)
 {
     _command            = command;
     _lineItemCommand    = lineItemCommand;
     _orderSubmitCommand = orderSubmitCommand;
 }
Пример #17
0
 public void TakeOrder(IOrderCommand order)
 {
     _orders.Add(order);
 }
Пример #18
0
 public OrderInvoker(Customer customer)
 {
     this.command = new OrderCommand(customer);
 }
Пример #19
0
        }// 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... ////////////////////////////
Пример #20
0
 public OrderController(IOrderCommand command, IOrderQuery query)
 {
     _command = command;
     _query   = query;
 }
Пример #21
0
 public void takeIOrderCommand(IOrderCommand IOrderCommand)
 {
     IOrderCommandList.Add(IOrderCommand);
 }
 public void ExecuteCommand(IOrderCommand command, MenuItem item)
 {
     command.Execute(Orders, item);
 }
Пример #23
0
 public void RemoveOrder(IOrderCommand command)
 {
     _orderCommands.Remove(command);
 }
Пример #24
0
 public void PlaceOrder(IOrderCommand order)
 {
     OrderList.Add(order);
 }
Пример #25
0
 internal void Invoke(IOrderCommand cmd)
 {
     cmd.Execute();
     commandsStack.Push(cmd);
 }
Пример #26
0
 public void TakeOrder(IOrderCommand order) => customerOrders.Add(order);
Пример #27
0
 private static bool IsCommandCreate(IOrderCommand c)
 {
     return(c.Version == OrderState.VersionZero);
 }
Пример #28
0
 public void TakeOrder(IOrderCommand order)
 {
     OrderList.Add(order);
 }
Пример #29
0
        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... ////////////////////////////