public async Task <IActionResult> GetClassById([FromRoute] long classId) { try { var cls = await _classService.GetClassByClassIdAsync(classId); var sems = (await _seminarService.ListSeminarByCourseIdAsync(cls.CourseId)).FirstOrDefault(s => (_classService.GetCallStatusByIdAsync(s.Id, cls.Id).Result?.Status ?? 0) == 1); return(Json(new { id = cls.Id, name = cls.Name, time = cls.ClassTime, site = cls.Site, courseId = cls.CourseId, calling = sems?.Id ?? -1, proportions = new { report = cls.ReportPercentage, presentation = cls.PresentationPercentage, c = cls.ThreePointPercentage, b = cls.FourPointPercentage, a = cls.FivePointPercentage } })); } catch (ArgumentException) { return(StatusCode(400, new { msg = "班级ID输入格式有误" })); } }
public async Task <IList <SeminarGroup> > ListSeminarGradeByCourseIdAsync(long userId, long courseId) { var seminarList = await _iSeminarService.ListSeminarByCourseIdAsync(courseId); //调用SeminarGroupService 中 SeminarGroup GetSeminarGroupByIdAsync(long seminarId, long userId) return(await Task.WhenAll(seminarList.Select(async t => await _iSeminarGroupService.GetSeminarGroupByIdAsync(t.Id, userId)))); }
public async Task <IActionResult> GetSeminarsByCourseId([FromRoute] long courseId, [FromQuery] bool embededGrade) { try { var seminars = await _seminarService.ListSeminarByCourseIdAsync(courseId); if (!embededGrade) { return(Json(seminars.Select(s => new { id = s.Id, name = s.Name, description = s.Description, groupingMethod = s.IsFixed == true ? "fixed" : "random", startTime = s.StartTime.ToString("YYYY-MM-dd"), endTime = s.EndTime.ToString("YYYY-MM-dd") }))); } return(Json(seminars.Select(s => new { id = s.Id, name = s.Name, description = s.Description, groupingMethod = s.IsFixed == true ? "fixed" : "random", startTime = s.StartTime.ToString("YYYY-MM-dd"), endTime = s.EndTime.ToString("YYYY-MM-dd"), grade = _seminarGroupService.GetSeminarGroupByIdAsync(s.Id, User.Id()).Result.FinalGrade }))); } catch (CourseNotFoundException) { return(StatusCode(404, new { msg = "未找到课程" })); } catch (ArgumentException) { return(StatusCode(400, new { msg = "课程ID格式错误" })); } }