コード例 #1
0
 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));
     }
 }
コード例 #2
0
        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));
        }