diff --git a/Api/District/DistrictController.cs b/Api/District/DistrictController.cs index d6cdb0b..522e762 100644 --- a/Api/District/DistrictController.cs +++ b/Api/District/DistrictController.cs @@ -64,13 +64,14 @@ [BindRequired] [FromQuery(Name = "division_name")] [HttpGet] public async Task GetAll( ApiResponseSortOrder sortOrder, + [FromQuery] ApiPagination apiPagination, [FromQuery(Name = "add_division")] bool addDivision = false, [FromQuery(Name = "add_sub_districts")] - bool addSubDistricts = false, - [FromQuery(Name = "page")] ushort page = 1, - [FromQuery(Name = "limit")] ushort limit = 1) + bool addSubDistricts = false) { - var result = await _districtService.FindAll(page, limit, sortOrder, addDivision, addSubDistricts); + var result = await _districtService.FindAll( + apiPagination.Page, apiPagination.Limit, sortOrder, addDivision, addSubDistricts); + return Ok(result.Select(x => x.ToDto(addDivision, addSubDistricts))); } } \ No newline at end of file diff --git a/Api/Division/DivisionController.cs b/Api/Division/DivisionController.cs index 9c6dad2..c993f16 100644 --- a/Api/Division/DivisionController.cs +++ b/Api/Division/DivisionController.cs @@ -62,14 +62,15 @@ [BindRequired] [FromRoute(Name = "division_name")] [HttpGet] public async Task GetAll( ApiResponseSortOrder sortOrder, - [FromQuery(Name = "page")] ushort page = 1, - [FromQuery(Name = "limit")] ushort limit = 1, + [FromQuery] ApiPagination apiPagination, [FromQuery(Name = "add_districts")] bool addDistricts = false, [FromQuery(Name = "add_sub_districts")] bool addSubDistricts = false ) { - var result = await _divisionService.FindAll(page, limit, sortOrder, addDistricts, addSubDistricts); + var result = await _divisionService.FindAll( + apiPagination.Page, apiPagination.Limit, sortOrder, addDistricts, addSubDistricts); + return Ok(result.Select(x => x.ToDto(addDistricts, addSubDistricts))); } } \ No newline at end of file diff --git a/Api/SubDistrict/SubDistrictController.cs b/Api/SubDistrict/SubDistrictController.cs index e2dd971..9f29f29 100644 --- a/Api/SubDistrict/SubDistrictController.cs +++ b/Api/SubDistrict/SubDistrictController.cs @@ -64,13 +64,13 @@ [BindRequired] [FromQuery(Name = "division_name")] [HttpGet] public async Task GetAll( ApiResponseSortOrder sortOrder, - [FromQuery(Name = "page")] ushort page = 1, - [FromQuery(Name = "limit")] ushort limit = 1, + [FromQuery] ApiPagination apiPagination, [FromQuery(Name = "add_division")] bool addDivision = false, [FromQuery(Name = "add_district")] bool addDistrict = false ) { - var result = await _subDistrictService.FindAll(page, limit, sortOrder, addDistrict, addDivision); + var result = await _subDistrictService.FindAll( + apiPagination.Page, apiPagination.Limit, sortOrder, addDistrict, addDivision); return Ok(result.Select(x => x.ToDto(true, true))); } } \ No newline at end of file diff --git a/Shared/ApiPagination.cs b/Shared/ApiPagination.cs new file mode 100644 index 0000000..df5340f --- /dev/null +++ b/Shared/ApiPagination.cs @@ -0,0 +1,7 @@ +namespace BdGeographicalData.Shared; + +public class ApiPagination +{ + public ushort Page { get; set; } = 1; + public ushort Limit { get; set; } = 1; +}