public IActionResult Create([FromBody] Category category) { if (!ModelState.IsValid) { return(View(category)); } try { var categoryToAdd = new Category { Name = category.Name, ParentID = category.ParentID, }; _service.AddNode(categoryToAdd); return(new JsonResult(categoryToAdd)); } catch (Exception ex) { return(RedirectToAction(nameof(Index))); } }