コード例 #1
0
        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));
        }
コード例 #2
0
 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));
     }
 }
コード例 #3
0
 public ActionResult Index()
 {
     return(View(service.GetEnterprises()));
 }
コード例 #4
0
 public ActionResult GetEnterprises()
 {
     return(Ok(_service.GetEnterprises()));
 }