Exemplo n.º 1
0
        public async Task <ActionResult <IEnumerable <SubjectDto> > > GetSubjecs(Guid studentId)
        {
            if (string.IsNullOrEmpty(studentId.ToString()))
            {
                return(NotFound());
            }
            var student = await _repository.GetStudentAsync(studentId);

            if (student == null)
            {
                return(BadRequest());
            }
            if (student?.Group == null)
            {
                return(BadRequest());
            }

            var subjects = await _repository.GetSubjectsForStudentAsync(student.Id);

            var subjectsDtos = subjects.Select(s => _mapper.Map <SubjectDto>(s)).ToList();

            return(subjectsDtos);
        }
Exemplo n.º 2
0
        public async Task <ActionResult <IEnumerable <SubjectDto> > > GetTimetableAsync(Guid studentId)
        {
            if (!_repository.StudentExists(studentId))
            {
                return(NotFound());
            }

            // get lessons
            // order lessons
            var student = await _repository.GetStudentAsync(studentId);

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

            var lessons = await _repository.GetLessonsForStudent(studentId);

            return(Ok(lessons));
        }