public List <Author> GetAll() { try { return(_appService.GetAll()); } catch (Exception ex) { throw ex; } }
public IActionResult GetAuthors(AuthorsResourceParameters authorsResourceParameters) //([FromQuery(Name = "page")]int pageNumber = 1, [FromQuery]int pageSize = 10) { //pageSize = pageSize > MaxPageSize ? MaxPageSize : pageSize; /* * The ModelBinding framework is smart because it will look for matching property name inside that class */ if (!_typeHelperService.TypeHasProperties <AuthorOutputDto>(authorsResourceParameters.Fields)) { return(BadRequest()); } var authors = _authorService.GetAll(authorsResourceParameters); var previousPageLink = authors.HasPrevious ? CreateAuthorsResourceUri(authorsResourceParameters, ResourceUriType.PreviousPage) : null; var nextPageLink = authors.HasNext ? CreateAuthorsResourceUri(authorsResourceParameters, ResourceUriType.NextPage) : null; var paginationMetadata = new { totalCount = authors.TotalCount, pageSize = authors.PageSize, currentPage = authors.CurrentPage, totalPages = authors.TotalPages, previousPageLink = previousPageLink, nextPageLink = nextPageLink }; Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(paginationMetadata)); //By Default, JsonResult returns a 200 (Ok) Http Status Code //return new JsonResult(authorsDTO); return(Ok(authors.ShapeData(authorsResourceParameters.Fields))); }
public IActionResult GetAuthors() { return(new OkObjectResult(_authorAppService.GetAll())); }
//GetAll Authors public ActionResult GetAll() { var model = _AuthorAppService.GetAll(); return(PartialView("GetAll", model)); }