Example #1
0
        /// <summary>
        /// Redirects to Validation view.
        /// </summary>
        /// <param name="palletId"></param>
        /// <returns></returns>
        public virtual ActionResult ValidatePallet(string palletId)
        {
            var box = _service.GetBoxesOfPallet(palletId).FirstOrDefault();

            //TC6: If the pallet doesn't contain any boxes.
            if (box == null)
            {
                ModelState.AddModelError("", string.Format("Pallet {0} does not contain any boxes.", palletId));
                return(RedirectToAction(this.Actions.Index(Sound.Error)));
            }
            var model = new ValidatePalletViewModel
            {
                SourcePalletId         = palletId,
                CustomerId             = box.CustomerId,
                SourcePalletAreaId     = box.IaId,
                SourcePalletLocationId = box.LocationId,
                //verified boxes count of passed customer criteria.
                VerifiedBoxes = _service.GetVerifiedBoxes(box.CustomerId, box.PoId, box.CustomerDcId, box.BucketId)
            };

            return(View(Views.ValidatePallet, model));
        }
Example #2
0
        public virtual ActionResult HandleBoxCount(ValidatePalletViewModel model)
        {
            //TC7: If nothing is passed when the UI asked for the no of boxes already placed on the pallet.
            if (model.BoxCount == null)
            {
                return(RedirectToAction(this.Actions.Index()));
            }
            var boxes = _service.GetBoxesOfPallet(model.SourcePalletId).ToArray();

            //TC8: when we doesn't scan any box for the pallet.
            if (!boxes.Any())
            {
                ModelState.AddModelError("", string.Format("Pallet {0} does not contain any boxes.", model.SourcePalletId));
                return(RedirectToAction(this.Actions.Index(Sound.Error)));
            }
            var box = boxes.FirstOrDefault();

            model.SourcePalletAreaId     = box.IaId;
            model.SourcePalletLocationId = box.LocationId;
            model.CustomerId             = box.CustomerId;
            model.VerifiedBoxes          = _service.GetVerifiedBoxes(box.CustomerId, box.PoId, box.CustomerDcId, box.BucketId);
            //TC9: When we entered exactly the same no. of boxes that are already placed on the pallet.
            if (boxes.Count() == model.BoxCount)
            {
                return(RedirectToAction(this.Actions.Destination(model.SourcePalletId)));
            }
            //TC10: When we entered wrong no. of boxes that are already on pallet on repetitive basis.
            if (model.IsConfirm)
            {
                _service.PutBoxOfPalletInSuspense(model.SourcePalletId);
                ModelState.AddModelError("", string.Format("Incorrect box count. Please scan each box on pallet {0} to validate it.", model.SourcePalletId));
                return(RedirectToAction(this.Actions.ValidateBoxesOnPallet(model.SourcePalletId, Sound.Error)));
            }
            model.IsConfirm = true;
            ModelState.AddModelError("", string.Format("Incorrect box count.Please enter correct box count on pallet {0}.", model.SourcePalletId));
            return(View(Views.ValidatePallet, model));
        }