예제 #1
0
        public IActionResult Get(string objectName)
        {
            ModelState.Clear();

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

            var entidades = repositoryRead.GetAll();

            if (entidades == null)
            {
                return(ResponseApi(null));
            }

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

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

            var models = mapper.Map(entidades, entidades.GetType(), typeof(IEnumerable <>).MakeGenericType(tipoModel));

            return(ResponseApi(models));
        }