public ActionResult Create(ProductVM prod) { try { // TODO: Add insert logic here //if (ModelState.IsValid) //{ crudFactory.CreateProduct(prod); //} return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
//[ValidateAntiForgeryToken] public JsonResult Create([FromBody] ProductVM prod) { try { // TODO: Add insert logic here if (prod != null) { crudFactory.CreateProduct(prod); return(Json(prod)); } else { return(Json(new ProductVM())); } //return RedirectToAction(nameof(Index)); } catch (Exception ex) { return(Json(ex.Message)); } }