Commit 8940e9317c51eb88f48300701a4e1fb864ca75b3
1 parent
db607025
add default sort
Showing
2 changed files
with
16 additions
and
2 deletions
Show diff stats
src/MapsDb/DataService/BusStopDs.cs
| @@ -45,7 +45,7 @@ namespace MapsDb.DataService | @@ -45,7 +45,7 @@ namespace MapsDb.DataService | ||
| 45 | return data.OrderByDescending(i => i.GetType().GetProperty(pagination.sort).GetValue(i, null)).ToList(); | 45 | return data.OrderByDescending(i => i.GetType().GetProperty(pagination.sort).GetValue(i, null)).ToList(); |
| 46 | 46 | ||
| 47 | default: | 47 | default: |
| 48 | - return data.OrderBy(i => i.GetType().GetProperty(pagination.sort).GetValue(i, null)).ToList(); | 48 | + return data.OrderByDescending(i => i.Id).ToList(); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | } | 51 | } |
src/MapsModels/DsModels/PaginationDsM.cs
| @@ -5,9 +5,23 @@ namespace MapsModels.DsModels | @@ -5,9 +5,23 @@ namespace MapsModels.DsModels | ||
| 5 | public const string ASC = "ASC"; | 5 | public const string ASC = "ASC"; |
| 6 | public const string DESC = "DESC"; | 6 | public const string DESC = "DESC"; |
| 7 | public int from { get; set; } | 7 | public int from { get; set; } |
| 8 | - public int perPage { get; set; } | 8 | + public int per_page; |
| 9 | public string sort { get; set; } | 9 | public string sort { get; set; } |
| 10 | + public int perPage{ | ||
| 11 | + get{ | ||
| 12 | + if(per_page == 0){ | ||
| 13 | + return 25; | ||
| 14 | + } | ||
| 15 | + return per_page; | ||
| 16 | + } | ||
| 17 | + set{ | ||
| 18 | + per_page = value; | ||
| 19 | + } | ||
| 20 | + } | ||
| 10 | public string orderType(){ | 21 | public string orderType(){ |
| 22 | + if(sort == null){ | ||
| 23 | + return null; | ||
| 24 | + } | ||
| 11 | if(sort.StartsWith("-")){ | 25 | if(sort.StartsWith("-")){ |
| 12 | sort = sort.Substring(1); | 26 | sort = sort.Substring(1); |
| 13 | return DESC; | 27 | return DESC; |