예제 #1
0
        public HttpResponseMessage GetAutor(int id)
        {
            Autor autor = null;

            using (var repository = new AutorRepository())
            {
                autor = repository.GetById(id);
            }


            return(Request.CreateResponse(HttpStatusCode.OK, autor));
        }
예제 #2
0
        public async Task <IActionResult> Get(int id)
        {
            try
            {
                var autor = await _repo.GetById(id);

                var results = _mapper.Map <AutorDto>(autor);
                return(Ok(results));
            }
            catch (Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Falha ao retornar dados"));
            }
        }
예제 #3
0
 public ActionResult <AutorViewModel> Get(int Id)
 {
     return(Ok(_mapper.Map <AutorViewModel>(_autorRepository.GetById(Id))));
 }