public IActionResult Post([FromBody] Course course) { if (ModelState.IsValid) { int newId = _courseRepo.Add(course); if (newId >= 0) { course.Id = newId; return(new CreatedResult("/course/post", course)); } else { return(new NotFoundResult()); } } return(BadRequest("Invalid Course Model")); }
public async Task AddAndSave(Course course) { _repo.Add(course); await _repo.Save(); }