public IActionResult GetTestByGroupId(int groupId) { TeacherDataAccess teacher = new TeacherDataAccess(); Mapper mapper = new Mapper(); List <TestDTO> tests = teacher.GetTestByGroupId(groupId); if (tests == null) { return(BadRequest("Группы не существет")); } return(Ok(mapper.ConvertTestDTOToTestModelList(teacher.GetTestByGroupId(groupId)))); }
public IActionResult GetGroupTestsAndResults(int userId, int groupId) { TeacherDataAccess teacher = new TeacherDataAccess(); Mapper mapper = new Mapper(); TeacherGroup groups = new TeacherGroup(); var g = groups.GetAll(); if (!g.Any(g => g.UserID == userId)) { return(BadRequest("Такой преподаватель отсутствует")); } if (!g.Any(g => g.GroupID == groupId)) { return(BadRequest("Группа отсутствует")); } if (!groups.GetAllByUserId(userId).Any(g => g.GroupID == groupId)) { return(BadRequest("Группа относится к другому преподавателю")); } List <TestDTO> tests = teacher.GetTestByGroupId(groupId); GroupStatistics gs = new GroupStatistics(groupId); Dictionary <int, double> statistic = gs.GetAverageResultsOfAllTestsByGroupId(groupId); return(Ok(mapper.ConvertTestDTOToGroupTestsAndResultsOutputModel(tests, statistic))); }