Exemplo n.º 1
0
        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));
            }
        }
Exemplo n.º 3
0
 public void Create(Category category)
 {
     db.Create(category);
 }