/// <summary> /// Handles destination pallet scan for mobile view. /// </summary> /// <param name="model"></param> /// Must Post:PalletId,AreaId /// <returns>view Palletize.mobile.cshtml</returns> /// <remarks> /// <para> /// UI ask for destination Pallet.On successfull scan Pallet info is shown and carton or pallet to be palletized is asked for scanning. /// </para> /// </remarks> public virtual ActionResult HandleDestinationPalletForMobile(DestinationPalletForMobileViewModel model) { if (!ModelState.IsValid || string.IsNullOrWhiteSpace(model.PalletId)) { return(View(Views.DestinationPallet_mobile, model)); } var pallet = _service.GetPallet(model.PalletId); string msg; if (pallet.CartonCount == 0) { msg = string.Format("Pallet {0} is a new pallet", model.PalletId); } else if (pallet.CartonAreaCount == 1) { msg = string.Format("Pallet {0} already has {1} cartons in area {2}", pallet.PalletId, pallet.CartonCount, pallet.MinShortName); } else { msg = string.Format("Pallet {0} has {1} cartons belonging to multiple areas, e.g. {2},{3}", pallet.PalletId, pallet.CartonCount, pallet.MinShortName, pallet.MaxShortName); } AddStatusMessage(msg); var pvm = new PalletizeMobileViewModel(); pvm.UpdatingRules.PalletId = model.PalletId; pvm.UpdatingRules.AreaId = model.AreaId; pvm.BuidingId = model.BuildingId; pvm.AreaShorName = model.ShortName; return(View(Views.Palletize_mobile, pvm)); }
/// <summary> /// Handles destination Area for Mobile view. Only non numbered areas qualify. /// </summary> /// <param name="model"></param> /// Must Post: AreaId /// <returns>view DestinationBuildingForMobile.mobile.cshtml if area belongs to multiple building. Else return view DestinationPallet_Mobile.cshtml.</returns> /// <remarks> /// <para> /// UI ask for area to place carton or pallet. On successful scan, next Ui ask for destination Pallet or Destination building. /// </para> /// </remarks> public virtual ActionResult HandleDestinationAreaForMobile(DestinationAreaForMobileViewModel model) { if (!ModelState.IsValid) { //TC1: Scan nothing. return(View(Views.DestinationArea_mobile, model)); } var areas = _service.GetCartonAreas(model.AreaShortName, null).ToArray(); if (!areas.Any()) { //TC2: Scanned invalid shortAreaname. ModelState.AddModelError("", string.Format("No such Area {0}", model.AreaShortName)); return(View(Views.DestinationArea_mobile, model)); } if (areas.Any(p => p.IsNumberedLocationArea)) { //Tc3: Scanned a non numbered area. ModelState.AddModelError("", "Please scan a non numbered Area"); return(View(Views.DestinationArea_mobile, model)); } var buildings = areas.Where(p => !string.IsNullOrWhiteSpace(p.Building)).Select(p => p.Building).ToArray(); if (buildings.Count() > 1) { // TC4: If multiple building found for passed areaShorName, ask user to enter one of building as suggested by system. return(View(Views.DestinationBuilding_mobile, new DestinationBuildingForMobileViewModel { BuildingList = buildings, AreaShortName = model.AreaShortName })); } var dpmv = new DestinationPalletForMobileViewModel { AreaId = areas.Select(p => p.AreaId).FirstOrDefault(), ShortName = model.AreaShortName }; //If areaShortname does not belong to any building we will treated shortname as areaId. if (!buildings.Any()) { dpmv.AreaId = model.AreaShortName; return(View(Views.DestinationPallet_mobile, dpmv)); } //TC5: If only one building found, we will skip to scan building, ask user to scan pallet directly. dpmv.BuildingId = buildings.FirstOrDefault(); return(View(Views.DestinationPallet_mobile, dpmv)); }
/// <summary> /// Handle destination building where pallet has to move. /// </summary> /// <param name="model"></param> /// <returns></returns> public virtual ActionResult HandleDestinationBuildingForMobile(DestinationBuildingForMobileViewModel model) { model.BuildingList = _service.GetCartonAreas(model.AreaShortName, null).Select(p => p.Building); if (!ModelState.IsValid) { //TC6: Nothing scanned. return(View(Views.DestinationBuilding_mobile, model)); } var result = _service.GetCartonAreas(model.AreaShortName, model.BuildingId); if (result == null || !result.Any()) { //TC7: Invalid building or for scanned shortName and building, no area found. ModelState.AddModelError("", string.Format("{0} is not a valid Building for Area {1}", model.BuildingId, model.AreaShortName)); return(View(Views.DestinationBuilding_mobile, model)); } var dpmv = new DestinationPalletForMobileViewModel { AreaId = result.FirstOrDefault().AreaId, ShortName = model.AreaShortName, BuildingId = model.BuildingId }; return(View(Views.DestinationPallet_mobile, dpmv)); }