🚧 working on sorting in api
Co-authored-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
		
							parent
							
								
									983a6af41a
								
							
						
					
					
						commit
						0354b7c098
					
				
					 1 changed files with 6 additions and 2 deletions
				
			
		|  | @ -47,8 +47,12 @@ public class MovieController: ControllerBase | ||||||
| 
 | 
 | ||||||
|             if (sort != null) { |             if (sort != null) { | ||||||
|                 if (!IsValidSort(sort)) return StatusCode(400, "Bad Request: Invalid sort-type"); |                 if (!IsValidSort(sort)) return StatusCode(400, "Bad Request: Invalid sort-type"); | ||||||
|                  |                 if (sort == "titleasc") movies = movies.OrderBy(m => m.Title); | ||||||
|             } |                 if (sort == "titledesc") movies = movies.OrderByDescending(m => m.Title); | ||||||
|  |                 if (sort == "yearasc") movies = movies.OrderBy(m => m.Year); | ||||||
|  |                 if (sort == "yeardesc") movies = movies.OrderByDescending(m => m.Year); | ||||||
|  |             }    | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
|             if (!IsValidPageNumber(pageNumber) || !IsValidPageSize(pageSize))  |             if (!IsValidPageNumber(pageNumber) || !IsValidPageSize(pageSize))  | ||||||
|                 return StatusCode(400, "Bad Request: Invalid page-size or page-number"); |                 return StatusCode(400, "Bad Request: Invalid page-size or page-number"); | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 haraldnilsen
						haraldnilsen