public ActionResult RawMaterial(RawMaterialModel rawMaterialModel) { if (!ModelState.IsValid) { string errorString = this.ValidationRawMaterial(rawMaterialModel); if (!string.IsNullOrEmpty(errorString)) { ViewBag.Validate = errorString; return(View(rawMaterialModel)); } } if (rawMaterialModel.Id > 0) { var result = _iRawMaterialService.UpdateRawMaterial(rawMaterialModel); if (result == -1) { ModelState.AddModelError("RawMaterialName", "Raw Material already exists"); return(View(rawMaterialModel)); } ViewBag.Result = _locService.GetLocalizedHtmlString("EditSuccss"); } else { var result = _iRawMaterialService.InsertRawMaterial(rawMaterialModel); if (result == -1) { ModelState.AddModelError("RawMaterialName", "Raw Material already exists"); return(View(rawMaterialModel)); } ViewBag.Result = _locService.GetLocalizedHtmlString("SaveSuccess"); } return(RedirectToAction("Index", "RawMaterial")); }
public async Task <IActionResult> Edit(int id, RawMaterialViewModel viewModel) { if (ModelState.IsValid) { await _service.UpdateRawMaterial(id, viewModel); return(RedirectToAction(nameof(Index))); } return(View(viewModel)); }