public IActionResult Create([FromBody] Category category) { Dictionary <string, object> res; try { res = CategoryData.Create(category); return(Ok(res)); } catch (System.Exception ex) { res = Service.createErrorRes(ex.Message); return(BadRequest(res)); } }
public ActionResult Create(CategoryModel category) { try { using (CategoryData data = new CategoryData()) { data.Create(category); } return(RedirectToAction(nameof(Index))); } catch { return(View(category)); } }
public void Create(Category category) { db.Create(category); }