// OrderCreate Stream - Starts here // GET: Customer/BarCode public ActionResult GetCustBarCode(bool isCust) { OrderGetCustBarCode model = new OrderGetCustBarCode(); model.BarCodeNumber = -1; model.IsCust = isCust; return(View(model)); }
public ActionResult GetCustBarCode(OrderGetCustBarCode model) { if (!ModelState.IsValid) { return(View(model)); } if (model.BarCodeNumber > 0) { var userId = User.Identity.GetUserId(); var BarCodeService = new BarCodeService(userId); BarCodeDetail newBarCodeDetail = BarCodeService.GetBarCodeByBarCode(model.BarCodeNumber); if (newBarCodeDetail == null) { ModelState.AddModelError("", $"'{model.BarCodeNumber}' is not a valid Bar Code Number. Please re-enter or contact a member of the Food Pantry team."); return(View(model)); } ; // Verify/Update Customer var custService = new CustomerService(userId); CustDetail custDetail = custService.GetCustByBarCodeId(newBarCodeDetail.BarCodeId); if (custDetail.CustomerId == 0) { ModelState.AddModelError("", $"'{model.BarCodeNumber}' is not assigned to a Customer. Please re-enter or contact a member of the Food Pantry team."); return(View(model)); } return(RedirectToAction(actionName: "Edit", controllerName: "Customer", routeValues: new { isCust = model.IsCust, isOrder = true, id = custDetail.CustomerId })); } else { // Create Customer return(RedirectToAction(actionName: "Create", controllerName: "Customer", routeValues: new { isOrder = true, barCodeId = 0 })); } }