Beispiel #1
0
        public IActionResult Get(string id)
        {
            _typer.SetCurrentTyper(typeof(Turma));
            var turma = repositoryRead.GetSingle(id) as Turma;

            if (turma == null)
            {
                return(NotFound(id));
            }

            _typer.SetCurrentTyper(typeof(Aluno));
            var alunos = repositoryRead.Search <Aluno>(x => x.TurmaId == id);

            turma.SetAlunos(alunos);

            _typer.SetCurrentTyper(typer: typeof(Domain.Entities.Chamada));
            var chamadas = repositoryRead.Search <Domain.Entities.Chamada>(x => x.TurmaId == id);

            turma.SetChamadas(chamadas);

            _typer.SetCurrentTyper(typeof(Turma));
            var tipoModelTurma = _typer.GetRefTyper("ViewModel", TyperAction.GetSingle);
            var model          = mapper.Map(turma, typeof(Turma), tipoModelTurma);

            return(ResponseApi(model));
        }
Beispiel #2
0
        public bool Run <T>(T entity) where T : class
        {
            var turma  = entity as Turma;
            var turmas = repository.Search <Turma>(x => x.Nome == turma.Nome && x.Id != turma.Id);

            if (turmas.Any())
            {
                return(false);
            }

            return(true);
        }