コード例 #1
0
        public IActionResult Get(string objectName, string id)
        {
            ModelState.Clear();

            if (!_typer.TrySetCurrentTyper(objectName))
            {
                return(BadRequest());
            }

            var tipoModel = _typer.GetRefTyper("ViewModel", TyperAction.GetSingle);

            var entidade = repositoryRead.GetSingle(id);

            if (tipoModel == null)
            {
                return(ResponseApi(entidade));
            }

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

            var model = mapper.Map(entidade, entidade.GetType(), tipoModel);

            return(ResponseApi(model));
        }
コード例 #2
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));
        }