Exemplo n.º 1
0
        public async Task <ActionResult <OrderAssignment> > PostOrderAssignment(OrderAssignment orderAssignment)
        {
            _context.OrderAssignments.Add(orderAssignment);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetOrderAssignment", new { id = orderAssignment.ID }, orderAssignment));
        }
        public void AddOrderAssignment(OrderOptimizedPossibilityDto orderOptimizedPossibility)
        {
            var orderAssignmentList = new List <OrderAssignment>();

            foreach (var r in orderOptimizedPossibility.OrderOptimizedDetails)
            {
                var orderAssignment = new OrderAssignment();

                orderAssignment.OrderDetailID       = r.OrderDetailID;
                orderAssignment.SupplierInventoryID = r.SupplierInventoryID;
                orderAssignment.Qty = r.Qty;
                orderAssignment.SupplierAcknowledgement = false;
                orderAssignment.BuyerAcknowledgement    = false;
                orderAssignment.VehicleAcknowledgement  = false;
                orderAssignment.IsDeleted = false;

                orderAssignmentList.Add(orderAssignment);

                var supllierInventory = supplierInventoryDataService.GetSupplierInventory(r.SupplierInventoryID);
                supllierInventory.ProcessingQty = supllierInventory.ProcessingQty - r.Qty;
                supllierInventory.AvailableQty  = supllierInventory.AvailableQty - r.Qty;
                supplierInventoryDataService.UpdateSupplierInventory(supllierInventory);
            }

            this.orderDataService.AddOrderAssignment(orderAssignmentList);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> PutOrderAssignment(int id, OrderAssignment orderAssignment)
        {
            if (id != orderAssignment.ID)
            {
                return(BadRequest());
            }

            _context.Entry(orderAssignment).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                /*if (!OrderAssignmentExists(id))
                 * {
                 *  return NotFound();
                 * }
                 * else
                 * {
                 *  throw;
                 * }*/
                throw;
            }

            return(NoContent());
        }
        public bool ProcessUnassignedOrders(int deliverySlotId)
        {
            bool retVal = false;
            var  orders = orderDataService.GetUnassignedOrdersbyDeliverySlot(deliverySlotId);

            foreach (var order in orders)
            {
                retVal = false;
                var orderPossibilities = optimizationEngine.SearchBestAvailbalities(order, order.OrderDetails);

                if (orderPossibilities != null && orderPossibilities.Count > 0)
                {
                    foreach (var orderPossibility in orderPossibilities)
                    {
                        var orderAssignmentList = new List <OrderAssignment>();

                        foreach (var r in orderPossibility.OrderOptimizedDetails)
                        {
                            var orderAssignment = new OrderAssignment();

                            orderAssignment.OrderDetailID       = r.OrderDetailID;
                            orderAssignment.SupplierInventoryID = r.SupplierInventoryID;
                            orderAssignment.Qty = r.Qty;
                            orderAssignment.SupplierAcknowledgement = false;
                            orderAssignment.BuyerAcknowledgement    = false;
                            orderAssignment.VehicleAcknowledgement  = false;
                            orderAssignment.IsDeleted = false;

                            orderAssignmentList.Add(orderAssignment);

                            var supllierInventory = supplierInventoryDataService.GetSupplierInventory(r.SupplierInventoryID);
                            supllierInventory.ProcessingQty = supllierInventory.ProcessingQty - r.Qty;
                            supllierInventory.AvailableQty  = supllierInventory.AvailableQty - r.Qty;
                            supplierInventoryDataService.UpdateSupplierInventory(supllierInventory);
                        }

                        this.orderDataService.AddOrderAssignment(orderAssignmentList);
                    }

                    var curOrder = this.orderDataService.GetOrder(order.ID);
                    order.Status = 2;
                    this.orderDataService.UpdateOrder();
                }
                retVal = true;
            }
            return(retVal);
        }
 public void UpdateOrderAssignment(OrderAssignment orderAssignment)
 {
     databaseContext.OrderAssignment.Update(orderAssignment);
     databaseContext.SaveChanges();
 }