Beispiel #1
0
        public async Task <IActionResult> Index()
        {
            if (HttpContext.User.Claims.Any(c => c.Value == TipoUsuario.Aluno.ToString()))
            {
                var user = await _userManager.GetUserAsync(HttpContext.User);

                var disciplina = _disciplinaRepository.GetAll().Where(c => c.CursoId == user.CursoId);
                var turmas     = _turmaRepository.GetAll().Where(c => disciplina.Any(d => c.DisciplinaId == d.DisciplinaId)).Include(c => c.Professor);
                return(View(turmas));
            }
            return(View(_turmaRepository.GetAll().Include(c => c.Professor).ToList()));
        }
Beispiel #2
0
 public IList <TurmaDTO> GetAll()
 {
     return(_turmaRepository
            .GetAll()
            .Select(turma => Mapper.Map <TurmaDTO>(turma))
            .ToList());
 }
Beispiel #3
0
        public override void Validate(Turma turma)
        {
            base.Validate(turma);

            if (string.IsNullOrEmpty(turma.Nome))
            {
                throw new InvalidOrNullRequiredPropertyException($"Propriedade {nameof(turma.Nome)} é obrigatória e não pode ser vasia.");
            }

            if (turma.Modalidade == null)
            {
                throw new InvalidOrNullRequiredPropertyException($"Propriedade {nameof(turma.Modalidade)} é obrigatória e não pode ser vasia.");
            }

            if (_repository.GetAll().Any(p => p.Nome.ToUpper() == turma.Nome.ToUpper() && p.Id != turma.Id))
            {
                throw new DuplicatedPropertyException($"Já existe uma turma com o nome {turma.Nome}.");
            }

            if (turma.LimiteMaximo.HasValue && turma.LimiteMaximo <= 0)
            {
                throw new NegativeValueException($"Quantidade do limite máximo não pode ser menor ou igual a zero.");
            }
        }
Beispiel #4
0
        public IEnumerable <Turma> GetAll()
        {
            var result = _repository.GetAll();

            return(result ?? throw new Exception("Não foram encontrados turmas cadastradas."));
        }
        public IActionResult GetList()
        {
            var list = _context.GetAll();

            return(Ok(list));
        }