コード例 #1
0
ファイル: HomeController.cs プロジェクト: sbist/dcmsconnect
        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));
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: sbist/dcmsconnect
        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)));
        }