public ActionResult Edit(long id) { HandlingUnitsPost handlingunits = _handlingunitsService.GetPost(id); if (handlingunits == null) { return(NotFound()); } ViewBag.ixHandlingUnitType = new SelectList(_handlingunitsService.selectHandlingUnitTypes().Select(x => new { x.ixHandlingUnitType, x.sHandlingUnitType }), "ixHandlingUnitType", "sHandlingUnitType", handlingunits.ixHandlingUnitType); //Custom Code Start | Replaced Code Block //Replaced Code Block Start //ViewBag.ixHeightUnit = new SelectList(_handlingunitsService.selectUnitsOfMeasurementNullable().Select( x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", handlingunits.ixHeightUnit); //ViewBag.ixLengthUnit = new SelectList(_handlingunitsService.selectUnitsOfMeasurementNullable().Select( x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", handlingunits.ixLengthUnit); //ViewBag.ixMaterialHandlingUnitConfiguration = new SelectList(_handlingunitsService.selectMaterialHandlingUnitConfigurationsNullable().Select( x => new { ixMaterialHandlingUnitConfiguration = x.Key, sMaterialHandlingUnitConfiguration = x.Value }), "ixMaterialHandlingUnitConfiguration", "sMaterialHandlingUnitConfiguration", handlingunits.ixMaterialHandlingUnitConfiguration); //ViewBag.ixPackingMaterial = new SelectList(_handlingunitsService.selectMaterialsNullable().Select(x => new { ixMaterial = x.Key, sMaterial = x.Value }), "ixMaterial", "sMaterial", handlingunits.ixPackingMaterial); //ViewBag.ixParentHandlingUnit = new SelectList(_handlingunitsService.selectHandlingUnitsNullable().Select( x => new { ixHandlingUnit = x.Key, sHandlingUnit = x.Value }), "ixHandlingUnit", "sHandlingUnit", handlingunits.ixParentHandlingUnit); //ViewBag.ixStatus = new SelectList(_handlingunitsService.selectStatusesNullable().Select( x => new { ixStatus = x.Key, sStatus = x.Value }), "ixStatus", "sStatus", handlingunits.ixStatus); //ViewBag.ixWeightUnit = new SelectList(_handlingunitsService.selectUnitsOfMeasurementNullable().Select( x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", handlingunits.ixWeightUnit); //ViewBag.ixWidthUnit = new SelectList(_handlingunitsService.selectUnitsOfMeasurementNullable().Select( x => new { ixUnitOfMeasurement = x.Key, sUnitOfMeasurement = x.Value }), "ixUnitOfMeasurement", "sUnitOfMeasurement", handlingunits.ixWidthUnit); //Replaced Code Block End ViewBag.ixHeightUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementLength().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", handlingunits.ixHeightUnit); ViewBag.ixLengthUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementLength().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", handlingunits.ixLengthUnit); ViewBag.ixPackingMaterial = new SelectList(_handlingunitsService.selectMaterialsNullable().Select(x => new { ixMaterial = x.Key, sMaterial = x.Value }), "ixMaterial", "sMaterial", handlingunits.ixPackingMaterial); ViewBag.ixMaterialHandlingUnitConfiguration = new SelectList(_handlingunitsService.selectMaterialHandlingUnitConfigurationsNullable().Select(x => new { ixMaterialHandlingUnitConfiguration = x.Key, sMaterialHandlingUnitConfiguration = x.Value }), "ixMaterialHandlingUnitConfiguration", "sMaterialHandlingUnitConfiguration", handlingunits.ixMaterialHandlingUnitConfiguration); ViewBag.ixParentHandlingUnit = new SelectList(_handlingunitsService.selectHandlingUnitsNullable().Select(x => new { ixHandlingUnit = x.Key, sHandlingUnit = x.Value }), "ixHandlingUnit", "sHandlingUnit", handlingunits.ixParentHandlingUnit); ViewBag.ixStatus = new SelectList(_handlingunitsService.selectStatusesNullable().Select(x => new { ixStatus = x.Key, sStatus = x.Value }), "ixStatus", "sStatus", handlingunits.ixStatus); ViewBag.ixWeightUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementWeight().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", handlingunits.ixWeightUnit); ViewBag.ixWidthUnit = new SelectList(_commonlyUsedSelects.selectUnitsOfMeasurementLength().Select(x => new { x.ixUnitOfMeasurement, x.sUnitOfMeasurement }), "ixUnitOfMeasurement", "sUnitOfMeasurement", handlingunits.ixWidthUnit); //Custom Code End return(View(handlingunits)); }
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); } ); }