public async Task ListCoursesByStudent_ValidId_Ok() { var obj = new EnrollmentDto { CourseId = 13, StudentId = 3 }; var actual = await _enrollmentLogic.EnrollStudent(obj); Assert.Greater(actual, 0); }
public async Task <IActionResult> EnrollStudentInACourse([FromBody] EnrollmentDto enrollStudent) { try { if (!ModelState.IsValid) { return(ValidationProblem("Invalid parameters")); } var enrollmentId = await _enrollmentLogic.EnrollStudent(enrollStudent); var actionName = ControllerContext.RouteData.Values["action"].ToString(); return(CreatedAtAction(actionName, new { enrollmentId })); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }