public ActionResult Create(StockIssueViewModel stockIssueViewModel) { var organisationId = UserOrganisationId; var centreId = UserCentreId; var isbalanceItem = stockIssueViewModel.BalanceQuantity >= stockIssueViewModel.StockIssue.IssuedQuantity; if (!isbalanceItem) { ModelState.AddModelError("", String.Format("Insufficient item, available item is {0}", stockIssueViewModel.BalanceQuantity)); return(View(stockIssueViewModel)); } if (ModelState.IsValid) { stockIssueViewModel.StockIssue.StockPurchaseId = stockIssueViewModel.StockPurchaseId; stockIssueViewModel.StockIssue.OrganisationId = organisationId; stockIssueViewModel.StockIssue.CentreId = centreId; stockIssueViewModel.StockIssue.BalanceQuantity = stockIssueViewModel.BalanceQuantity - stockIssueViewModel.StockIssue.IssuedQuantity; stockIssueViewModel.StockIssue = NidanBusinessService.CreateStockIssue(organisationId, stockIssueViewModel.StockIssue); return(RedirectToAction("Index", "StockPurchase")); } return(View(stockIssueViewModel)); }