|
1 | 1 | using System.Collections.Generic; |
2 | 2 | using System.Linq; |
3 | | -using System; |
4 | 3 | using System.Net; |
5 | 4 | using System.Threading.Tasks; |
6 | 5 | using AutoMapper; |
@@ -282,58 +281,6 @@ public async Task<IActionResult> GetMentorWorkspace(long courseId, string mentor |
282 | 281 | return Ok(workspace); |
283 | 282 | } |
284 | 283 |
|
285 | | - private async Task<WorkspaceViewModel> CourseToMentorWorkspaceViewModel(CourseDTO course, CourseDTO mentorCourseView) |
286 | | - { |
287 | | - var courseGroups = (course.Groups ?? Array.Empty<GroupViewModel>()) |
288 | | - .Where(g => !string.IsNullOrWhiteSpace(g.Name)) |
289 | | - .ToArray(); |
290 | | - |
291 | | - var filteredGroups = (mentorCourseView.Groups ?? Array.Empty<GroupViewModel>()) |
292 | | - .Where(g => !string.IsNullOrWhiteSpace(g.Name)) |
293 | | - .ToArray(); |
294 | | - |
295 | | - var selectedGroups = filteredGroups.Length == courseGroups.Length |
296 | | - ? Array.Empty<GroupViewModel>() |
297 | | - : filteredGroups; |
298 | | - |
299 | | - var selectedGroupsStudentIds = selectedGroups |
300 | | - .SelectMany(g => g.StudentsIds ?? Array.Empty<string>()) |
301 | | - .ToHashSet(); |
302 | | - |
303 | | - var selectedStudentIdsWithoutGroups = (mentorCourseView.CourseMates ?? Array.Empty<CourseMateViewModel>()) |
304 | | - .Select(t => t.StudentId) |
305 | | - .Where(studentId => !selectedGroupsStudentIds.Contains(studentId)) |
306 | | - .ToArray(); |
307 | | - |
308 | | - var selectedStudentsData = selectedStudentIdsWithoutGroups.Length == (course.CourseMates?.Length ?? 0) |
309 | | - ? Array.Empty<AccountDataDto>() |
310 | | - : await AuthServiceClient.GetAccountsData(selectedStudentIdsWithoutGroups); |
311 | | - |
312 | | - var selectedStudents = selectedStudentsData |
313 | | - .Where(x => x != null) |
314 | | - .OrderBy(x => x.Surname) |
315 | | - .ThenBy(x => x.Name) |
316 | | - .ToArray(); |
317 | | - |
318 | | - var availableHomeworks = selectedGroups.Any() |
319 | | - ? (course.Homeworks ?? Array.Empty<HomeworkViewModel>()) |
320 | | - .Where(h => h.GroupId == null || selectedGroups.Any(g => g.Id == h.GroupId)) |
321 | | - .ToArray() |
322 | | - : course.Homeworks ?? Array.Empty<HomeworkViewModel>(); |
323 | | - |
324 | | - var filteredHomeworks = mentorCourseView.Homeworks ?? Array.Empty<HomeworkViewModel>(); |
325 | | - var selectedHomeworks = filteredHomeworks.Length == availableHomeworks.Length |
326 | | - ? Array.Empty<HomeworkViewModel>() |
327 | | - : filteredHomeworks; |
328 | | - |
329 | | - return new WorkspaceViewModel |
330 | | - { |
331 | | - Homeworks = selectedHomeworks, |
332 | | - Students = selectedStudents, |
333 | | - Groups = selectedGroups, |
334 | | - }; |
335 | | - } |
336 | | - |
337 | 284 | private async Task<CourseViewModel> ToCourseViewModel(CourseDTO course) |
338 | 285 | { |
339 | 286 | var studentIds = course.CourseMates.Select(t => t.StudentId).ToArray(); |
|
0 commit comments