public async Task <StudentScheduleEntry> GetStudentScheduleAsync(int studentUsi) { var data = await _studentRepository.GetStudentScheduleAsync(studentUsi, _dateProvider.Monday(), _dateProvider.Friday()); var scheduleDays = (from m in data group m by m.Date into g select new ScheduleDay { Date = g.Key, ScheduleName = g.First().BellScheduleName, Events = g.Select(x => new ScheduleEvent { ScheduleName = x.BellScheduleName, Date = x.Date, CourseTitle = x.CourseTitle, StartTime = x.StartTime.SetTimeOnDate(g.Key), EndTime = x.EndTime.SetTimeOnDate(g.Key), ClassroomIdentificationCode = x.ClassroomIdentificationCode, FirstName = x.FirstName, MiddleName = x.MiddleName, LastSurname = x.LastSurname, }).ToList() }).ToList(); return(new StudentScheduleEntry { Days = scheduleDays }); }