public virtual ActionResult StartSkipUcc(MasterModelWithPallet model) { Contract.Requires(this.ModelState.IsValid, "Attributes should prevent invalid model from invoking this action"); SkipUccViewModel suvm = new SkipUccViewModel(this.HttpContext.Session); suvm.Sound = 'W'; return(View(suvm)); }
public virtual ActionResult SkipUcc(SkipUccViewModel model) { Contract.Requires(this.ModelState.IsValid, "Attributes should prevent invalid model from invoking this action"); //TC 27 : Enter empty on confirm UCC screen if (string.IsNullOrEmpty(model.ConfirmScan)) { this.AddStatusMessage("UCC skipping cancelled"); //return RedirectToAction("Carton", "Home"); return(RedirectToAction(MVC_BoxPick.BoxPick.Home.AcceptCarton())); } //TC 28 : Enter S on confirm UCC Skip screen or if (model.ConfirmScan == "S" || model.ConfirmScan == "s") { model.ConfirmScan = model.UccIdToPick; } //var fieldName = ReflectionHelpers.FieldNameFor((SkipUccViewModel m) => m.ConfirmScan); var fieldName = model.NameFor(m => m.ConfirmScan); //TC 29 : Scan anything different from UCC To Pick from pallet if (!model.ConfirmScan.Equals(model.UccIdToPick)) { ModelState.AddModelError(fieldName, "The confirmation UCC scan did not match the original scan"); } if (!ModelState.IsValidField(fieldName)) { // Confirm scan does not match original return(RedirectToAction(MVC_BoxPick.BoxPick.Home.AcceptCarton())); } try { _repos.Value.RemoveBoxFromPallet(model.ConfirmScan, model.CurrentPalletId); this.AddStatusMessage(string.Format("UCC {0} removed from Pallet {1}. Please place a red dot on the UCC label.", model.ConfirmScan, model.CurrentPalletId)); } catch (DbException ex) { ModelState.AddModelError("", ex.Message); } if (!ModelState.IsValid) { return(RedirectToAction(MVC_BoxPick.BoxPick.Home.AcceptCarton())); } Contract.Assert(this.ModelState.IsValid, "We have already handled the invalid cases"); //Requery pallet Pallet pallet = null; try { pallet = _repos.Value.RetrievePalletInfo(model.CurrentPalletId); //TODO : Needs to define if (pallet == null) { ModelState.AddModelError("", string.Format("Pallet {0} is not available for picking anymore. Please start over.", model.CurrentPalletId)); } 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("", string.Format("Pallet {0} is invalid. Please contact System Administrator", model.CurrentPalletId)); } } } catch (DbException ex) { ModelState.AddModelError("", ex.Message); } if (!ModelState.IsValid) { model.Map(null); return(RedirectToAction(MVC_BoxPick.BoxPick.Home.AcceptPallet())); } if (pallet.IsFull) { switch (model.PickMode) { case PickModeType.ADR: string palletId = model.CurrentPalletId; model.Map(null); return(RedirectToAction(this.Actions.Print(palletId))); case PickModeType.ADREPPWSS: model.Map(null); return(RedirectToAction(MVC_BoxPick.BoxPick.Home.AcceptPallet())); default: throw new NotImplementedException(); } } else { return(RedirectToAction(MVC_BoxPick.BoxPick.Home.AcceptCarton())); } }