public async Task <IActionResult> Create([FromBody] AddCategoryInputDto addinput) { if (!ModelState.IsValid) { return(BadRequest()); } var result = await CategoryServise.AddCategory(addinput); return(Ok(result)); }
public async Task <IActionResult> OnPost() { try { if (!ModelState.IsValid) { return(Page()); } await categoryServise.AddCategory(NewCategory); State = true; return(RedirectToPage("./Category")); } catch (Exception e) { State = false; ViewData["Error"] = e.Message; return(Page()); } }