public async Task <ActionResult> CreateCategory(ProductCategory category) { if (ModelState.IsValid) { var newCategory = await _repo.AddCategoryAsync(category); return(Ok(newCategory)); } else { var messages = string.Join(";", ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage)); return(StatusCode(400, messages)); } }