コード例 #1
0
        public async Task <IActionResult> GetItemsToShip(long orderId, long warehouseId)
        {
            var currentUser = await _workContext.GetCurrentUser();

            var order = _orderRepository.Query().FirstOrDefault(x => x.Id == orderId);

            if (order == null)
            {
                return(NotFound());
            }

            if (!User.IsInRole("admin") && order.VendorId != currentUser.VendorId)
            {
                return(BadRequest(new { error = "You don't have permission to manage this order" }));
            }

            var model = new ShipmentForm
            {
                OrderId     = orderId,
                WarehouseId = warehouseId
            };

            var itemsToShip = await _shipmentService.GetItemToShip(orderId, warehouseId);

            foreach (var item in itemsToShip)
            {
                item.QuantityToShip = item.OrderedQuantity - item.ShippedQuantity;
            }

            model.Items = itemsToShip;
            return(Ok(model));
        }
コード例 #2
0
        public void ApskaiciuotiSiuntosDydi_IvesimeKrepselioPrekiuSuBendruTuriu48160_TikimesKadDydisNebusL()
        {
            DuomenuBaze duomenuBaze = new DuomenuBaze();

            DuomenuBaze.Krepselio_Prekes.Add(new Krepselio_preke("Veliava", 10, 400, 120));
            DuomenuBaze.Krepselio_Prekes.Add(new Krepselio_preke("Ausines", 8, 10, 16));
            ShipmentForm shipmentForm = new ShipmentForm();

            shipmentForm.ApskaiciuotiSiuntosDydi();
            Assert.AreNotEqual('S', shipmentForm._Siunta.Siuntos_dydis);
        }
コード例 #3
0
        public void ApskaiciuotiSuma_IvesimeKrepselioPrekiuSuBendraSuma8080IrSuDydziuL_TikimesGautiSuma8120()
        {
            DuomenuBaze duomenuBaze = new DuomenuBaze();

            DuomenuBaze.Krepselio_Prekes.Add(new Krepselio_preke("Veliava", 10, 800, 120));
            DuomenuBaze.Krepselio_Prekes.Add(new Krepselio_preke("Ausines", 8, 10, 16));
            ShipmentForm shipmentForm = new ShipmentForm();

            shipmentForm.ApskaiciuotiSiuntosDydi();
            shipmentForm.ApskaiciuotiSuma();
            Assert.AreEqual(8120, shipmentForm._Siunta.Suma);
        }
コード例 #4
0
        public async Task <IActionResult> Post([FromBody] ShipmentForm model)
        {
            if (ModelState.IsValid)
            {
                var currentUser = await _workContext.GetCurrentUser();

                var shipment = new Shipment
                {
                    OrderId        = model.OrderId,
                    WarehouseId    = model.WarehouseId,
                    CreatedById    = currentUser.Id,
                    TrackingNumber = model.TrackingNumber,
                    CreatedOn      = DateTimeOffset.Now,
                    UpdatedOn      = DateTimeOffset.Now
                };

                if (!User.IsInRole("admin"))
                {
                    shipment.VendorId = currentUser.VendorId;
                }

                foreach (var item in model.Items)
                {
                    if (item.QuantityToShip <= 0)
                    {
                        continue;
                    }

                    var shipmentItem = new ShipmentItem
                    {
                        Shipment    = shipment,
                        Quantity    = item.QuantityToShip,
                        ProductId   = item.ProductId,
                        OrderItemId = item.OrderItemId
                    };

                    shipment.Items.Add(shipmentItem);
                }

                var result = await _shipmentService.CreateShipment(shipment);

                if (result.Success)
                {
                    return(CreatedAtAction(nameof(Get), new { id = shipment.Id }, null));
                }

                return(BadRequest(result.Error));
            }

            return(BadRequest(ModelState));
        }
コード例 #5
0
        public async Task <IActionResult> GetItemsToShip(long orderId, long warehouseId)
        {
            var model = new ShipmentForm
            {
                OrderId     = orderId,
                WarehouseId = warehouseId
            };

            var itemsToShip = await _shipmentService.GetItemToShip(orderId, warehouseId);

            foreach (var item in itemsToShip)
            {
                item.QuantityToShip = item.OrderedQuantity - item.ShippedQuantity;
            }

            model.Items = itemsToShip;
            return(Ok(model));
        }
コード例 #6
0
        private void newShipmentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var rc = from Control c
                     in m_reportTab.Controls
                     where c is ReportControl
                     select c;
            ReportControl report = rc.First() as ReportControl;

            var ic = from Control c
                     in m_inventoryTab.Controls
                     where c is InventoryControl
                     select c;

            InventoryControl inventory = ic.First() as InventoryControl;

            ShipmentForm sf = new ShipmentForm(ref m_register,
                                               ref inventory,
                                               ref report);

            sf.ShowDialog();
        }