public IActionResult GetEnterprises([FromBody] EnterpriseQueryFilter filters) { if (!User.Identity.IsAuthenticated) { throw new AuthenticationException(); } var enterprises = _enterpriseService.GetEnterprises(filters); var enterpriseDto = _mapper.Map <IEnumerable <EnterpriseDto> >(enterprises); var metadata = new Metadata { TotalCount = enterprises.TotalCount, PageSize = enterprises.PageSize, CurrentPage = enterprises.CurrentPage, TotalPages = enterprises.TotalPages, HasNextPage = enterprises.HasNextPage, HasPreviousPage = enterprises.HasPreviousPage, NextPageUrl = _uriService.GetPostPaginationUri(filters, Url.RouteUrl(nameof(GetEnterprises))).ToString(), PreviousPageUrl = _uriService.GetPostPaginationUri(filters, Url.RouteUrl(nameof(GetEnterprises))).ToString() }; var response = new ApiResponse <IEnumerable <EnterpriseDto> >(enterpriseDto) { Meta = metadata }; Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(metadata)); return(Ok(response)); }
public ActionResult <IEnumerable <EnterpriseModel> > GetEnterprises(string orderBy = "id") { try { return(Ok(service.GetEnterprises(orderBy))); } catch (BadOperationRequest ex) { return(BadRequest(ex.Message)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public ActionResult Index() { return(View(service.GetEnterprises())); }
public ActionResult GetEnterprises() { return(Ok(_service.GetEnterprises())); }