public void TestReceivedPackagePage_Distributed() { var controller = new PackageTransitController(employeeRepository, packageRepository); controller.ControllerContext = new ENetCareMVC.UnitTest.FakeClasses.FakeControllerContext(controller, "*****@*****.**", new string[] { "Agent" }); Package package = packageRepository.GetPackageWidthBarCode("11623542734"); List <SelectedPackage> spList = new List <SelectedPackage>(); SelectedPackage sp = new SelectedPackage() { BarCode = package.BarCode }; spList.Add(sp); var model = new PackageTransitReceiveViewModel() { SelectedPackages = spList, BarCode = package.BarCode, ReceiveDate = DateTime.Today }; var result = controller.ReceiveSave(model) as ViewResult; var modelReturned = result.Model as PackageTransitReceiveViewModel; Assert.AreEqual("ReceiveComplete", result.ViewName); Assert.AreEqual("Successful!", modelReturned.SelectedPackages[0].ProcessResultMessage); }
public ActionResult ReceiveSave(PackageTransitReceiveViewModel model) { var packageService = GetPackageService(); var employeeService = GetEmployeeService(); var employee = GetCurrentEmployee(); DistributionCentre locationCentre = employeeService.GetDistributionCentre(employee.LocationCentreId); if (ModelState.IsValid && model.SelectedPackages != null && model.SelectedPackages.Any()) { foreach (var package in model.SelectedPackages) { Result result = packageService.Receive(package.BarCode, locationCentre, model.ReceiveDate); if (result.Success) { package.ProcessResultMessage = "Successful!"; } else { package.ProcessResultMessage = result.ErrorMessage; } } return(View("ReceiveComplete", model)); } else { if (model.SelectedPackages == null || !model.SelectedPackages.Any()) { model.SelectedPackages = new List <SelectedPackage>(); ModelState.AddModelError("", PackageResult.NoBarCodesSelected); } return(View("Receive", model)); } }
public ActionResult Receive() { PackageTransitReceiveViewModel model = new PackageTransitReceiveViewModel(); model.SelectedPackages = new List <SelectedPackage>(); model.ReceiveDate = DateTime.Today; return(View(model)); }
public ActionResult ReceiveRemove(PackageTransitReceiveViewModel model) { int id = -1; string buttonValue = HttpContext.Request["action"]; var operations = new ReceiveSelectedBarCodesOperations(); operations.Remove(model, buttonValue); return(View("Receive", model)); }
public ActionResult ReceiveAdd(PackageTransitReceiveViewModel model) { var operations = new ReceiveSelectedBarCodesOperations(); var result = operations.Add(model); if (!result.Succeeded) { ModelState.AddModelError("", result.ErrorMessage); } return(View("Receive", model)); }
public ActionResult ReceiveClose(PackageTransitReceiveViewModel model) { return(RedirectToAction("Index", "Home")); }