public async Task <ActionResult <List <Course> > > GetAllCoursesWithDefiniteLecturer(int lecturerID) { if (Validation.IsAnyInputObjectDataNotSpecified(new List <object> { lecturerID })) { return(BadRequest("Error: lecturer ID must be specified (with non-zero value)")); } using (var connection = new SqlConnection(Configuration.GetConnectionString("DefaultConnection"))) { try { connection.Open(); var coursesWithDefiniteLecturer = await CoursesLecturersRepository.GetAllCoursesWithDefiniteLecturerAsync(connection, lecturerID); if (coursesWithDefiniteLecturer.Count == 0) { return(NotFound("There aren't any courses with this lecturer")); } return(coursesWithDefiniteLecturer); } catch (Exception ex) { return(BadRequest(ex.Message)); } } }