public TimetableModelDto GetTimetable(int timetableId)
        {
            TimetableModelDto timetable = Context.Timetables
                                          .AsNoTracking()
                                          .Include(t => t.Groups)
                                          .Include(t => t.Subjects)
                                          .ThenInclude(s => s.Info)
                                          .Where(t => t.Id == timetableId)
                                          .Select(t => new TimetableModelDto
            {
                Key      = t.Key,
                Groups   = t.Groups.Select(g => g.Number),
                Subjects = t.Subjects.Select(s => new SubjectShortDto
                {
                    Id         = s.Id,
                    Title      = s.Info.Title,
                    Teachers   = s.Info.Teachers,
                    IsApproved = s.IsApproved
                }),
                IsApproved = t.IsApproved
            })
                                          .SingleOrDefault();

            return(timetable);
        }
Beispiel #2
0
        public IActionResult Timetable(int id)
        {
            TimetableModelDto timetableDto = TimetableService.GetTimetable(id);

            if (timetableDto == null)
            {
                return(NotFound());
            }

            var timetableViewModel = Mapper.Map <TimetableViewModel>(timetableDto);

            return(View(timetableViewModel));
        }