예제 #1
0
        public ActionResult Edit(long id)
        {
            OutboundCarrierManifestsPost outboundcarriermanifests = _outboundcarriermanifestsService.GetPost(id);

            if (outboundcarriermanifests == null)
            {
                return(NotFound());
            }
            ViewBag.ixCarrier  = new SelectList(_outboundcarriermanifestsService.selectCarriers().Select(x => new { x.ixCarrier, x.sCarrier }), "ixCarrier", "sCarrier", outboundcarriermanifests.ixCarrier);
            ViewBag.ixFacility = new SelectList(_outboundcarriermanifestsService.selectFacilities().Select(x => new { x.ixFacility, x.sFacility }), "ixFacility", "sFacility", outboundcarriermanifests.ixFacility);
            ViewBag.ixPickupInventoryLocation = new SelectList(_outboundcarriermanifestsService.selectInventoryLocationsNullable().Select(x => new { ixInventoryLocation = x.Key, sInventoryLocation = x.Value }), "ixInventoryLocation", "sInventoryLocation", outboundcarriermanifests.ixPickupInventoryLocation);
            ViewBag.ixStatus = new SelectList(_outboundcarriermanifestsService.selectStatuses().Select(x => new { x.ixStatus, x.sStatus }), "ixStatus", "sStatus", outboundcarriermanifests.ixStatus);

            return(View(outboundcarriermanifests));
        }
예제 #2
0
        public void shipInventoryForManifest(Int64 ixOutboundCarrierManifest, string UserName)
        {
            var ixStatusActive   = _commonLookUps.getStatuses().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault();
            var ixStatusInactive = _commonLookUps.getStatuses().Where(s => s.sStatus == "Inactive").Select(s => s.ixStatus).FirstOrDefault();
            var ixStatusComplete = _commonLookUps.getStatuses().Where(s => s.sStatus == "Complete").Select(s => s.ixStatus).FirstOrDefault();
            var ixInventoryUnitTransactionContext = _commonLookUps.getInventoryUnitTransactionContext().Where(c => c.sInventoryUnitTransactionContext == "Handling Units Shipping").Select(c => c.ixInventoryUnitTransactionContext).FirstOrDefault();

            var outboundshipments = _outboundshipmentsService.IndexDb().Where(sh => sh.ixOutboundCarrierManifest == ixOutboundCarrierManifest && sh.ixStatus == ixStatusActive)
                                    .Select(sh => sh.ixOutboundShipment).ToList();

            var outboundorders = _outboundordersRepository.IndexDb().Where(o => o.ixStatus == ixStatusActive)
                                 .Join(outboundshipments, o => o.ixOutboundShipment, sh => sh, (o, sh) => new { O = o, Sh = sh })
                                 .Select(x => x.O.ixOutboundOrder).ToList();

            var outboundorderlines = _outboundorderlinesService.IndexDb()
                                     .Join(outboundorders, ol => ol.ixOutboundOrder, o => o, (ol, o) => new { Ol = ol, O = o })
                                     .Select(x => x.Ol.ixOutboundOrderLine).ToList();

            var outboundorderlinesinventoryallocation = _outboundorderlinesinventoryallocationService.IndexDb()
                                                        .Join(outboundorderlines, ola => ola.ixOutboundOrderLine, ol => ol, (ola, ol) => new { Ola = ola, Ol = ol })
                                                        .Where(x => x.Ola.nBaseUnitQuantityPicked == x.Ola.nBaseUnitQuantityAllocated).Select(x => x.Ola.ixOutboundOrderLineInventoryAllocation).ToList();

            var outboundorderlinepacking = _outboundorderlinepackingService.IndexDb().Where(x => x.ixStatus == ixStatusActive)
                                           .Join(outboundorderlines, p => p.ixOutboundOrderLine, ol => ol, (p, ol) => new { P = p, Ol = ol })
                                           .Select(x => x.P.ixOutboundOrderLinePack).ToList();

            var outboundorderlinesshipped = _outboundorderlinepackingService.IndexDb().Where(x => x.ixStatus == ixStatusActive)
                                            .Join(outboundorderlines, p => p.ixOutboundOrderLine, ol => ol, (p, ol) => new { P = p, Ol = ol })
                                            .Select(x => new { ixOutboundOrderLine = x.P.ixOutboundOrderLine, nBaseUnitQuantityPacked = x.P.nBaseUnitQuantityPacked }).ToList();

            var handlingunitsToShip = _outboundorderlinepackingService.IndexDb().Where(x => x.ixStatus == ixStatusActive)
                                      .Join(outboundorderlines, p => p.ixOutboundOrderLine, ol => ol, (p, ol) => new { P = p, Ol = ol })
                                      .Select(x => x.P.ixHandlingUnit).Distinct().ToList();

            var inventoryunitsToShip = _inventoryunitsService.IndexDbPost().Where(x => x.nBaseUnitQuantity > 0)
                                       .Join(handlingunitsToShip, iu => iu.ixHandlingUnit, hu => hu, (iu, hu) => new { Iu = iu, Hu = hu })
                                       .Select(x => x.Iu.ixInventoryUnit).Distinct().ToList();

            inventoryunitsToShip.ForEach(x =>
            {
                var inventoryunit = _inventoryunitsService.GetPost(x);
                inventoryunit.nBaseUnitQuantity = 0;
                inventoryunit.ixStatus          = ixStatusInactive;
                inventoryunit.UserName          = UserName;
                _inventoryunitsService.Edit(inventoryunit, ixInventoryUnitTransactionContext);
            }
                                         );

            handlingunitsToShip.ForEach(x =>
            {
                var handlingunit      = _handlingunitsService.GetPost(x);
                handlingunit.ixStatus = ixStatusInactive;
                handlingunit.UserName = UserName;
                _handlingunitsService.Edit(handlingunit);
            }
                                        );

            //Now we set the statuses to complete
            var outboundcarriermanifest = _outboundcarriermanifestsService.GetPost(ixOutboundCarrierManifest);

            outboundcarriermanifest.ixStatus = ixStatusComplete;
            outboundcarriermanifest.UserName = UserName;
            _outboundcarriermanifestsService.Edit(outboundcarriermanifest);

            outboundshipments.ForEach(x =>
            {
                var outboundshipment      = _outboundshipmentsService.GetPost(x);
                outboundshipment.ixStatus = ixStatusComplete;
                outboundshipment.UserName = UserName;
                _outboundshipmentsService.Edit(outboundshipment);
            }
                                      );

            outboundorders.ForEach(x =>
            {
                var outboundorder      = _outboundordersRepository.GetPost(x);
                outboundorder.ixStatus = ixStatusComplete;
                outboundorder.UserName = UserName;
                _outboundordersRepository.RegisterEdit(outboundorder);
                _outboundordersRepository.Commit();
            }
                                   );

            outboundorderlines
            .Join(outboundorderlinesshipped, ol => ol, ols => ols.ixOutboundOrderLine, (ol, ols) => new { OL = ol, Ols = ols })
            .Select(o => new { ixOutboundOrderLine = o.Ols.ixOutboundOrderLine, nBaseUnitQuantityPacked = o.Ols.nBaseUnitQuantityPacked }).ToList()
            .ForEach(x =>
            {
                var outboundorderline = _outboundorderlinesService.GetPost(x.ixOutboundOrderLine);
                outboundorderline.nBaseUnitQuantityShipped += x.nBaseUnitQuantityPacked;
                outboundorderline.ixStatus = ixStatusComplete;
                outboundorderline.UserName = UserName;
                _outboundorderlinesService.Edit(outboundorderline);
            }
                     );

            outboundorderlinesinventoryallocation.ForEach(x =>
            {
                var outboundorderlineinventoryallocation      = _outboundorderlinesinventoryallocationService.GetPost(x);
                outboundorderlineinventoryallocation.ixStatus = ixStatusComplete;
                outboundorderlineinventoryallocation.UserName = UserName;
                _outboundorderlinesinventoryallocationService.Edit(outboundorderlineinventoryallocation);
            }
                                                          );

            outboundorderlinepacking.ForEach(x =>
            {
                var outboundorderlinepack      = _outboundorderlinepackingService.GetPost(x);
                outboundorderlinepack.ixStatus = ixStatusComplete;
                outboundorderlinepack.UserName = UserName;
                _outboundorderlinepackingService.Edit(outboundorderlinepack);
            }
                                             );
        }