Exemplo n.º 1
0
        public void TestDiscardPackageExpired()
        {
            IPackageRepository  packageRepository  = new MockPackageRepository();
            IEmployeeRepository employeeRepository = new MockEmployeeRepository();
            var controller = new PackageController(employeeRepository, packageRepository);

            Package package = packageRepository.GetPackageWidthBarCode("65985438786");

            List <SelectedPackage> spList = new List <SelectedPackage>();

            SelectedPackage sp = new SelectedPackage();

            sp.BarCode                 = package.BarCode;
            sp.CentreId                = package.CurrentLocation.CentreId;
            sp.ExpirationDate          = package.ExpirationDate;
            sp.PackageId               = package.PackageId;
            sp.PackageTypeId           = package.PackageType.PackageTypeId;
            sp.CurrentEmployeeUserName = "******";

            spList.Add(sp);

            var model = new PackageDiscardViewModel()
            {
                SelectedPackages = spList,
            };

            var result = controller.DiscardSave(model) as ViewResult;

            var modelReturned = result.Model as PackageDiscardViewModel;

            Assert.AreEqual("DiscardComplete", result.ViewName);
            Assert.AreEqual("Succeeded", modelReturned.SelectedPackages[0].ProcessResultMessage);
        }
Exemplo n.º 2
0
        public ActionResult Discard()
        {
            var model = new PackageDiscardViewModel();

            model.SelectedPackages = new List <SelectedPackage>();

            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult DiscardRemove(PackageDiscardViewModel model)
        {
            string buttonValue = HttpContext.Request["action"];

            var operations = new DiscardSelectedBarCodesOperations();

            operations.Remove(model, buttonValue);

            return(View("Discard", model));
        }
Exemplo n.º 4
0
        public ActionResult DiscardAdd(PackageDiscardViewModel model)
        {
            var operations = new DiscardSelectedBarCodesOperations();

            var result = operations.Add(model);

            if (!result.Succeeded)
            {
                ModelState.AddModelError("", result.ErrorMessage);
            }

            return(View("Discard", model));
        }
Exemplo n.º 5
0
        public ActionResult DiscardSave(PackageDiscardViewModel model)
        {
            var packageService  = GetPackageService();
            var employeeService = GetEmployeeService();

            Result result = new Result();

            if (ModelState.IsValid && model.SelectedPackages != null && model.SelectedPackages.Any())
            {
                foreach (var package in model.SelectedPackages)
                {
                    DistributionCentre  selectedCentre = employeeService.GetDistributionCentre(package.CentreId);
                    StandardPackageType spt            = packageService.GetStandardPackageType(package.PackageTypeId);
                    Employee            employee       = employeeService.GetEmployeeByUserName(package.CurrentEmployeeUserName);

                    result = packageService.Discard(package.BarCode, selectedCentre, employee, package.ExpirationDate, spt, package.PackageId);
                    if (result.Success)
                    {
                        package.ProcessResultMessage = "Succeeded";
                    }
                    else
                    {
                        package.ProcessResultMessage = result.ErrorMessage;
                    }
                }

                return(View("DiscardComplete", model));
            }

            if (model.SelectedPackages == null || !model.SelectedPackages.Any())
            {
                model.SelectedPackages = new List <SelectedPackage>();
                ModelState.AddModelError("", PackageResult.NoBarCodesSelected);
            }
            return(View("Discard", model));
        }
Exemplo n.º 6
0
 public ActionResult DiscardClose(PackageDiscardViewModel model)
 {
     return(RedirectToAction("Index", "Home"));
 }