public JsonResult CreateSupplier(Suppliers pSuppliers) { try { var result = dataSource.Add(pSuppliers); return(Json(new { result = result > 0 }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { result = false, msg = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Add(SuppliersBaseViewModel viewModel) { if (ModelState.IsValid) { var supplier = viewModel.Supplier; _suppliersRepository.Add(supplier); TempData["Message"] = "Le fournisseur a été ajouté a la liste."; return(RedirectToAction("Index")); } viewModel.Init(_suppliersRepository); return(View(viewModel)); }