Exemplo n.º 1
0
        public TimetableApiDto GetApprovedTimetable(int timetableId)
        {
            TimetableApiDto timetable = Context.Timetables
                                        .Where(t => t.IsApproved)
                                        .Include(t => t.Groups)
                                        .Include(t => t.Subjects)
                                        .ThenInclude(s => s.Days)
                                        .ThenInclude(d => d.Periods)
                                        .Include(t => t.Subjects)
                                        .ThenInclude(s => s.Info)
                                        .Select(t => new TimetableApiDto
            {
                Id       = t.Id,
                Key      = t.Key,
                Hash     = t.Hash,
                Groups   = t.Groups.Select(g => g.Number).ToList(),
                Subjects = t.Subjects.Select(s => new SubjectApiDto
                {
                    Id                = s.Id,
                    Title             = s.Info.Title,
                    Teachers          = s.Info.Teachers,
                    LectureStartDate  = s.Info.LectureStartDate,
                    LectureEndDate    = s.Info.LectureEndDate,
                    PracticeStartDate = s.Info.PracticeStartDate,
                    PracticeEndDate   = s.Info.PracticeEndDate,
                    Days              = s.Days.Select(d => new SchoolDayApiDto
                    {
                        Id              = d.Id,
                        Day             = d.Day,
                        IsDayOfEvenWeek = d.IsDayOfEvenWeek,
                        Periods         = d.Periods.Select(p => new PeriodApiDto
                        {
                            Id            = p.Id,
                            Number        = p.Number,
                            Cabinet       = p.Cabinet,
                            Subgroup      = p.Subgroup,
                            IsLecture     = p.IsLecture,
                            Option        = p.Option,
                            OptionDate    = p.OptionDate,
                            OptionCabinet = p.OptionCabinet
                        }).ToList()
                    }).ToList()
                }).ToList()
            })
                                        .SingleOrDefault(t => t.Id == timetableId);

            return(timetable);
        }
Exemplo n.º 2
0
        public JsonResult GetApprovedTimetable(int id)
        {
            if (id == 0)
            {
                return(Json(new object { }));
            }
            TimetableApiDto timetableDto = _timetableService.GetApprovedTimetable(id);

            if (timetableDto == null)
            {
                return(Json(new object { }));
            }

            var timetable = _mapper.Map <TimetableModel>(timetableDto);

            return(Json(timetable));
        }