public ActionResult Edit([Bind("ixOutboundShipment,sOutboundShipment,ixFacility,ixCompany,ixCarrier,sCarrierConsignmentNumber,ixStatus,ixAddress,ixOutboundCarrierManifest")] OutboundShipmentsPost outboundshipments) { if (ModelState.IsValid) { outboundshipments.UserName = User.Identity.Name; _outboundshipmentsService.Edit(outboundshipments); return(RedirectToAction("Index")); } ViewBag.ixAddress = new SelectList(_outboundshipmentsService.selectAddresses().Select(x => new { x.ixAddress, x.sAddress }), "ixAddress", "sAddress", outboundshipments.ixAddress); ViewBag.ixCarrier = new SelectList(_outboundshipmentsService.selectCarriers().Select(x => new { x.ixCarrier, x.sCarrier }), "ixCarrier", "sCarrier", outboundshipments.ixCarrier); ViewBag.ixCompany = new SelectList(_outboundshipmentsService.selectCompanies().Select(x => new { x.ixCompany, x.sCompany }), "ixCompany", "sCompany", outboundshipments.ixCompany); ViewBag.ixFacility = new SelectList(_outboundshipmentsService.selectFacilities().Select(x => new { x.ixFacility, x.sFacility }), "ixFacility", "sFacility", outboundshipments.ixFacility); ViewBag.ixOutboundCarrierManifest = new SelectList(_outboundshipmentsService.selectOutboundCarrierManifestsNullable().Select(x => new { ixOutboundCarrierManifest = x.Key, sOutboundCarrierManifest = x.Value }), "ixOutboundCarrierManifest", "sOutboundCarrierManifest", outboundshipments.ixOutboundCarrierManifest); ViewBag.ixStatus = new SelectList(_outboundshipmentsService.selectStatuses().Select(x => new { x.ixStatus, x.sStatus }), "ixStatus", "sStatus", outboundshipments.ixStatus); return(View(outboundshipments)); }
public Task Edit(PickBatchesPost pickbatchesPost) { // Additional validations // Pre-process // Process this._pickbatchesRepository.RegisterEdit(pickbatchesPost); try { this._pickbatchesRepository.Commit(); } catch (Exception ex) { this._pickbatchesRepository.Rollback(); // Log exception throw; } // Post-process //Custom Code Start | Added Code Block if (pickbatchesPost.ixStatus == _commonLookUps.getStatuses().Where(s => s.sStatus == "Complete").Select(s => s.ixStatus).FirstOrDefault()) { // We check if the shipment associated with the orders on the batch has been manifested. If not we try and find an active manifest else we create a new one and add the shipment to it var outboundShipments = _outboundordersRepository.IndexDb().Where(x => x.ixPickBatch == pickbatchesPost.ixPickBatch).Select(x => x.ixOutboundShipment).ToList(); var outboundShipmentsNotManifested = _outboundshipmentsService.IndexDb().Where(x => x.ixOutboundCarrierManifest == null) .Join(outboundShipments, os => os.ixOutboundShipment, o => o, (os, o) => new { Os = os, O = o }) .Select(s => s.Os.ixOutboundShipment).ToList(); outboundShipmentsNotManifested.ForEach(x => { var outboundShipment = _outboundshipmentsService.GetPost(x); if ( _outboundcarriermanifestsService.IndexDb().Where(m => m.ixFacility == outboundShipment.ixFacility && m.ixCarrier == outboundShipment.ixCarrier && m.ixStatus == _commonLookUps.getStatuses().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault() ).Any()) { var ixOutboundCarrierManifest = _outboundcarriermanifestsService.IndexDb().Where(m => m.ixFacility == outboundShipment.ixFacility && m.ixCarrier == outboundShipment.ixCarrier && m.ixStatus == _commonLookUps.getStatuses().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault() ).Select(m => m.ixOutboundCarrierManifest).FirstOrDefault(); outboundShipment.ixOutboundCarrierManifest = ixOutboundCarrierManifest; outboundShipment.UserName = pickbatchesPost.UserName; _outboundshipmentsService.Edit(outboundShipment); } else { OutboundCarrierManifestsPost outboundCarrierManifestsPost = new OutboundCarrierManifestsPost(); outboundCarrierManifestsPost.ixFacility = outboundShipment.ixFacility; outboundCarrierManifestsPost.ixCarrier = outboundShipment.ixCarrier; outboundCarrierManifestsPost.ixPickupInventoryLocation = _shipping.getTrailerDoorSuggestion(outboundShipment.ixFacility); outboundCarrierManifestsPost.ixStatus = _commonLookUps.getStatuses().Where(s => s.sStatus == "Active").Select(s => s.ixStatus).FirstOrDefault(); outboundCarrierManifestsPost.dtScheduledPickupAt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day) + _outboundshipmentsService.CarriersDb().Where(c => c.ixCarrier == outboundShipment.ixCarrier).Select(c => c.dtScheduledPickupTime).FirstOrDefault(); outboundCarrierManifestsPost.UserName = pickbatchesPost.UserName; var ixOutboundCarrierManifest = _outboundcarriermanifestsService.Create(outboundCarrierManifestsPost).Result; outboundShipment.ixOutboundCarrierManifest = ixOutboundCarrierManifest; outboundShipment.UserName = pickbatchesPost.UserName; _outboundshipmentsService.Edit(outboundShipment); } } ); } //Custom Code End return(Task.CompletedTask); }
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); } ); }