示例#1
0
        public async Task <IActionResult> GetLast24H()
        {
            var result = await JobsSql.GetLast24H();


            return(new OkObjectResult(result));
        }
示例#2
0
        public async Task <IActionResult> GetWithPaging(
            [FromQuery, SwaggerParameter("How many offers you want to return per page", Required = true)]
            int _limit,
            [FromQuery, SwaggerParameter("The page number to start from. The first page is 0.", Required = true)]
            int _page, [FromQuery] string OfferId_like,
            [FromQuery] string _sort,
            [FromQuery] string _order,
            [FromQuery] bool export,
            [FromQuery] int?exportType)
        {
            _page--;

            if (OfferId_like != null && OfferId_like.Length > 200)
            {
                OfferId_like = null;
            }

            var result = await JobsSql.GetWithPaging(_limit, _page, OfferId_like, _sort, _order);

            HttpContext.Response.Headers["access-control-expose-headers"] = "X-Total-Count";
            HttpContext.Response.Headers["X-Total-Count"] = result.total.ToString();

            if (export)
            {
                if (exportType == 0)
                {
                    return(File(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(result.results)), "application/json",
                                "jobs.json", false));
                }
                else if (exportType == 1)
                {
                    return(File(Encoding.UTF8.GetBytes(CsvSerializer.SerializeToCsv(result.results)), "text/csv", "jobs.csv",
                                false));
                }
            }

            return(new OkObjectResult(result.results));
        }