public async Task<ActionResult> SaveAssignmentCategory(AssignmentCategoryViewModel model) { //ModelState.AddModelError("EmailSubject", "Test Error."); if (ModelState.IsValid) { var category = new AssignmentCategory() { Id = model.Id, OwnerLevel = model.OwnerLevel, OwnerId = model.OwnerId, Title = model.Title }; if (string.IsNullOrEmpty(model.Id)) await _assignmentManager.InsertCategoryAsync(category); else await _assignmentManager.UpdateCategoryAsync(category); return Ok(category); } return BadRequest(ModelState); }