public virtual ActionResult AcceptPalletInUcc(UccViewModel model) { Contract.Requires(this.ModelState.IsValid, "Attributes should prevent invalid model from invoking this action"); var fieldName = model.NameFor(m => m.ScannedUccId); return(BeginPartialPickPallet(model, fieldName, Views.Ucc)); }
public virtual ActionResult AcceptCarton(CartonViewModel model) { Contract.Requires(this.ModelState.IsValid, "Attributes should prevent invalid model from invoking this action"); //TC12 : Scan null Or empty enter in Carton Text box on carton page. if (string.IsNullOrWhiteSpace(model.ScannedCartonId)) { // Clear existing carton if any return(View(Views.Carton, model)); } //TC13 : Enter S on textbox on carton page. if (model.ScannedCartonId == "S" || model.ScannedCartonId == "s") { return(RedirectToAction(MVC_BoxPick.BoxPick.Confirm.SkipUcc())); } model.ScannedCartonId = model.ScannedCartonId.ToUpper(); // Validate carton. If box is returned as null then carton was not pickable. var box = _repos.Value.GetBoxForCarton(model.ScannedCartonId, model.CurrentPalletId, model.UccIdToPick); //TC14 : If no information of scanned carton found // Check whether the scanned carton can be placed in current pallet. if (box == null) { ModelState.AddModelError(model.NameFor(m => m.ScannedCartonId), "Carton cannot be picked for this pallet"); } if (!ModelState.IsValid) { //Bad carton return(View(Views.Carton, model)); } //TODO : Needs to define if (!model.SuspenseFlag && model.CurrentLocationId != box.AssociatedCarton.LocationId && !string.IsNullOrEmpty(model.CartonIdToPick)) { // Now carton is being picked from another location. Ask to mark it in suspense. return(RedirectToAction(MVC_BoxPick.BoxPick.Confirm.Actions.SuspenseCarton(model.ScannedCartonId))); } var uvm = new UccViewModel(this.HttpContext.Session); uvm.SetLastCartonAndLocation(box.AssociatedCarton.CartonId, box.AssociatedCarton.LocationId); switch (model.PickMode) { //TC16 : When Pickmode of pallet is ADR case PickModeType.ADR: uvm.ScannedUccId = box.UccId; return(AcceptUcc(uvm)); //TC17 : When Pickmode of pallet is ADREPPWSS case PickModeType.ADREPPWSS: return(View(Views.Ucc, uvm)); default: throw new NotImplementedException(); } }
public virtual ActionResult AcceptCartonInUcc(UccViewModel uvm) { //TC22 : Scan nothing or empty enter on UCC page. if (string.IsNullOrEmpty(uvm.ScannedUccId)) { return(View(Views.Ucc, uvm)); } return(RedirectToAction(Actions.AcceptUccInCarton() .AddRouteValue(ReflectionHelpers.NameFor((CartonViewModel m) => m.ScannedCartonId), uvm.ScannedUccId))); }
public virtual ActionResult AcceptUcc(UccViewModel model) { model.ScannedUccId = model.ScannedUccId.ToUpper(); var fieldName = model.NameFor(m => m.ScannedUccId); //TC19 : Needs to validate that only proposed Ucc can be removed from pallet if (model.ScannedUccId != model.UccIdToPick && model.PickMode == PickModeType.ADREPPWSS) { ModelState.AddModelError(fieldName, "Please scan the UCC being proposed."); } if (!ModelState.IsValid) { return(View(Views.Ucc, model)); } try { // Pick box now _repos.Value.PickCarton(model.ScannedUccId, model.LastCartonId, model.ProductivityStartTime.Value); if (model.CountRequiredVAS > 0) { this.AddStatusMessage(string.Format("Carton {0} associated with Box {1} picked.VAS required on this box please take this box to VAS area", model.LastCartonId, model.ScannedUccId)); } else { this.AddStatusMessage(string.Format("Carton {0} associated with Box {1} picked.", model.LastCartonId, model.ScannedUccId)); } model.SetLastUccPicked(model.ScannedUccId); } catch (DbException ex) { // Carton not suitable for box ModelState.AddModelError(fieldName, ex.Message); } if (!ModelState.IsValid) { return(View(Views.Carton, new CartonViewModel(this.Session))); } Contract.Assert(this.ModelState.IsValid, "We have already handled the invalid cases"); // Requery pallet Pallet pallet = null; var fieldCurrentPallet = model.NameFor(m => m.CurrentPalletId); try { pallet = _repos.Value.RetrievePalletInfo(model.CurrentPalletId); //TC20 : Pick a pallet that is available for only one box. if (pallet == null) { ModelState.AddModelError("", string.Format("Pallet {0} does not available for picking anymore, Please start over", model.CurrentPalletId)); } //TC21 : Pick a pallet whose last box is remain to get picked. else if (pallet.IsFull) { this.AddStatusMessage(string.Format("Pallet {0} has completed. Please scan new pallet.", model.CurrentPalletId)); } else { model.Map(pallet); if (!TryValidateModel(model)) { ModelState.AddModelError(fieldCurrentPallet, string.Format("Pallet {0} is invalid. Please contact System Administrator", model.CurrentPalletId)); } } } catch (DbException ex) { ModelState.AddModelError(fieldCurrentPallet, ex.Message); } if (!ModelState.IsValid) { // Get rid of this invalid pallet model.Map(null); return(RedirectToAction(Actions.AcceptPallet())); } if (pallet.IsFull) { switch (model.PickMode) { case PickModeType.ADR: string palletId = model.CurrentPalletId; model.Map(null); return(RedirectToAction(MVC_BoxPick.BoxPick.Confirm.Print(palletId))); case PickModeType.ADREPPWSS: model.Map(null); return(RedirectToAction(Actions.AcceptPallet())); default: throw new NotImplementedException(); } } return(View(Views.Carton, new CartonViewModel(this.Session))); }