protected void AddInventoryAdjustmentCommands(int userId, Order order, OrderLumberLineItem[] lumberLineItems, OrderMiscellaneousLineItem[] miscLineItems) { var transaction = MakeInventoryTransaction(userId, order); var adjustmentMultiplier = AdjustmentMultiplier.GetByOrderType(order.OrderType.OrderTypeEnum); var adjustLumberProductQuantityCommands = lumberLineItems.Select( i => new AdjustLumberProductQuantity(transaction, i.LumberProductId, i.Quantity * adjustmentMultiplier, order.ApplyInventoryQuantityChanges)).ToList(); var adjustMiscellaneousProductQuantityCommands = miscLineItems.Select( i => new AdjustMiscellaneousProductQuantity(transaction, i.MiscellaneousProductId, i.Quantity * adjustmentMultiplier, order.ApplyInventoryQuantityChanges)).ToList(); if (!adjustLumberProductQuantityCommands.Any() && !adjustMiscellaneousProductQuantityCommands.Any()) { return; } AddCreateInventoryTransactionCommand(transaction); Commands.AddRange(adjustLumberProductQuantityCommands); Commands.AddRange(adjustMiscellaneousProductQuantityCommands); }
private void AddInventoryAdjustmentCommands(int userId, Order order, OrderLumberLineItem[] lumberLineItems, OrderMiscellaneousLineItem[] miscLineItems) { var transaction = MakeInventoryTransaction(userId, order); var adjustmentMultiplier = AdjustmentMultiplier.GetByOrderType(order.OrderType.OrderTypeEnum); var lumberQuantityUpdateCommands = GetLumberProductQuantityAdjustmentCommands(transaction, order.OrderLumberLineItems, lumberLineItems.ToList(), adjustmentMultiplier, order.ApplyInventoryQuantityChanges); var miscQuantityUpdateCommands = GetMiscellaneousProductQuantityAdjustmentCommands(transaction, order.OrderMiscellaneousLineItems, miscLineItems.ToList(), adjustmentMultiplier, order.ApplyInventoryQuantityChanges); if (!lumberQuantityUpdateCommands.Any() && !miscQuantityUpdateCommands.Any()) { return; } AddCreateInventoryTransactionCommand(transaction); Commands.AddRange(lumberQuantityUpdateCommands); Commands.AddRange(miscQuantityUpdateCommands); }
public DeleteOrderBuilder(int userId, Order order) { order = GetOrder(order.Id); if (order.OrderStatus.OrderStatusEnum == OrderStatuses.Deleted) { return; } var orderLumberLineItems = order.OrderLumberLineItems; var orderMiscLineItems = order.OrderMiscellaneousLineItems; var transaction = MakeInventoryTransaction(userId, order); AddCreateInventoryTransactionCommand(transaction); var adjustmentMultiplier = AdjustmentMultiplier.GetByOrderType(order.OrderType.OrderTypeEnum); AddLumberProductQuantityAdjustmentCommands(transaction, orderLumberLineItems, adjustmentMultiplier, order.ApplyInventoryQuantityChanges); AddMiscellaneousProductQuantityAdjustmentCommands(transaction, orderMiscLineItems, adjustmentMultiplier, order.ApplyInventoryQuantityChanges); order.OrderStatus = DatabaseCommandDirectory.Instance.GetOrderStatusByEnum(OrderStatuses.Deleted, order.OrderTypeId); order.OrderStatusId = order.OrderStatus.Id; Commands.Add(new SaveOrder(order)); }