public ActionResult <Transcript> AddGrade(StudentGrade studentGrade) { if (!ModelState.IsValid) { return(BadRequest()); } if (!_studentsRepo.Exists(studentGrade.StudentID)) { return(NotFound("Student not found")); } if (!_coursesRepo.Exists(studentGrade.CourseID)) { return(NotFound("Course not found")); } var addedGrade = _repo.AddGrade(studentGrade); if (addedGrade == null) { return(BadRequest("Failed to add grade. Please check request values and try again")); // ideally we would let the consumer know exactly why the request failed } return(Created("Grade was added", addedGrade)); }