File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change
1
+ using System . Diagnostics ;
1
2
using System . Text . Json ;
2
3
using Microsoft . AspNetCore . Mvc ;
4
+ using Microsoft . CodeAnalysis . Operations ;
3
5
using Umbraco . Cms . Core ;
4
6
using Umbraco . Cms . Core . Models ;
5
7
using Umbraco . Cms . Core . Models . PublishedContent ;
@@ -39,7 +41,7 @@ public async Task<IActionResult> GetOverviewData(int pageNumber = 1, int pageSiz
39
41
switch ( orderBy )
40
42
{
41
43
case nameof ( PageMetric . CarbonRating ) :
42
- filter = x => x . CarbonRating ;
44
+ filter = x => GetCarbonRatingOrder ( x . CarbonRating ) ;
43
45
break ;
44
46
case nameof ( PageMetric . RequestDate ) :
45
47
filter = x => x . RequestDate ;
@@ -126,5 +128,28 @@ public async Task<IActionResult> SavePageData([FromQuery] int pageId, [FromBody]
126
128
await _pageMetricService . AddPageMetric ( pageMetric ) ;
127
129
return Ok ( true ) ;
128
130
}
131
+
132
+ private int GetCarbonRatingOrder ( string carbonRating )
133
+ {
134
+ switch ( carbonRating )
135
+ {
136
+ case "A+" :
137
+ return 1 ;
138
+ case "A" :
139
+ return 2 ;
140
+ case "B" :
141
+ return 3 ;
142
+ case "C" :
143
+ return 4 ;
144
+ case "D" :
145
+ return 5 ;
146
+ case "E" :
147
+ return 6 ;
148
+ case "F" :
149
+ return 7 ;
150
+ default :
151
+ return 7 ;
152
+ }
153
+ }
129
154
}
130
155
}
You can’t perform that action at this time.
0 commit comments