public ActionResult AssignProduct(AssignProductModel model) { if (ModelState.IsValid) { string currentUser = HttpContext.User.Identity.Name; int selRow = model.FormSubmit.RowID; int j = 0; int RequirementID = 0; string Reason = ""; if (selRow == 0) { string[] prodToReduce = model.FormSubmit.AssignedQuanity.Split(','); for (int i = 0; i < prodToReduce.Length; i++) { string[] stockqunaity = prodToReduce[i].Split('-'); int stockID = Int32.Parse(stockqunaity[0]); int quantityReduce = Int32.Parse(stockqunaity[1]); bool reduceQuantity = _accountService.ReduceQuantity(stockID, quantityReduce); if (reduceQuantity == true) { bool returnresult = _accountService.AssignProduct(model.FormSubmit.UserName, quantityReduce, model.FormSubmit.ProductID, currentUser, stockID, RequirementID, Reason); if (returnresult == true) { j = j + 1; } } else { ViewBag.SuccessMsg = "Error raised while assigning product please try again!"; } } ModelState.Clear(); ViewBag.SuccessMsg = "Product assigned to user successfully"; } else { bool returnresult = _accountService.AssignProductUpdate(model.FormSubmit.UserName, model.FormSubmit.Quantity, model.FormSubmit.ProductID, selRow); if (returnresult == true) { ModelState.Clear(); ViewBag.SuccessMsg = "Assigned product updated successfully"; } else { ViewBag.Failuremessage = "Unable to update please try again later!"; } } } ViewBag.CategoryList = _accountService.GetAllCategory(); ViewBag.SubCategoryList = _accountService.SubCategory(); ViewBag.ProductList = _accountService.ProductList(); ViewBag.UsersInfo = _accountService.GetAllUsers(); AssignProductModel sem = new AssignProductModel(); List <ProductAssignedList> AllProductAssignedData = _accountService.AssignedDataList(); ProductAssignedDisplay md = new ProductAssignedDisplay(); md.AllProductAssignedData = AllProductAssignedData; sem.DisplayData = md; return(View(sem)); }