| | 1 | | using MRA.DTO.Models; |
| | 2 | |
|
| | 3 | | namespace MRA.Services.Models.Drawings; |
| | 4 | |
|
| | 5 | | public static class DrawingSortExtensions |
| | 6 | | { |
| | 7 | | public static IEnumerable<DrawingModel> SortByLatest(this IEnumerable<DrawingModel> drawings) |
| | 8 | | { |
| 35 | 9 | | return drawings.OrderBy(x => x.DateObject); |
| | 10 | | } |
| | 11 | |
|
| | 12 | | public static IEnumerable<DrawingModel> SortByOldest(this IEnumerable<DrawingModel> drawings) |
| | 13 | | { |
| 35 | 14 | | return drawings.OrderByDescending(x => x.DateObject); |
| | 15 | | } |
| | 16 | |
|
| | 17 | | public static IEnumerable<DrawingModel> SortByNameAZ(this IEnumerable<DrawingModel> drawings) |
| | 18 | | { |
| 35 | 19 | | return drawings.OrderBy(x => x.Name); |
| | 20 | | } |
| | 21 | |
|
| | 22 | | public static IEnumerable<DrawingModel> SortByNameZA(this IEnumerable<DrawingModel> drawings) |
| | 23 | | { |
| 35 | 24 | | return drawings.OrderByDescending(x => x.Name); |
| | 25 | | } |
| | 26 | |
|
| | 27 | | public static IEnumerable<DrawingModel> SortByLikeAscending(this IEnumerable<DrawingModel> drawings) |
| | 28 | | { |
| 35 | 29 | | return drawings.OrderBy(x => x.Likes); |
| | 30 | | } |
| | 31 | |
|
| | 32 | | public static IEnumerable<DrawingModel> SortByLikeDescending(this IEnumerable<DrawingModel> drawings) |
| | 33 | | { |
| 35 | 34 | | return drawings.OrderByDescending(x => x.Likes); |
| | 35 | | } |
| | 36 | |
|
| | 37 | | public static IEnumerable<DrawingModel> SortByViewsAscending(this IEnumerable<DrawingModel> drawings) |
| | 38 | | { |
| 35 | 39 | | return drawings.OrderBy(x => x.Views); |
| | 40 | | } |
| | 41 | |
|
| | 42 | | public static IEnumerable<DrawingModel> SortByViewsDescending(this IEnumerable<DrawingModel> drawings) |
| | 43 | | { |
| 35 | 44 | | return drawings.OrderByDescending(x => x.Views); |
| | 45 | | } |
| | 46 | |
|
| | 47 | | public static IEnumerable<DrawingModel> SortByAuthorScoreAscending(this IEnumerable<DrawingModel> drawings) |
| | 48 | | { |
| 167 | 49 | | return drawings.OrderBy(x => x.ScoreCritic).ThenBy(x => x.ScorePopular).ThenBy(x => x.VotesPopular); |
| | 50 | | } |
| | 51 | |
|
| | 52 | | public static IEnumerable<DrawingModel> SortByAuthorScoreDescending(this IEnumerable<DrawingModel> drawings) |
| | 53 | | { |
| 167 | 54 | | return drawings.OrderByDescending(x => x.ScoreCritic).ThenByDescending(x => x.ScorePopular).ThenByDescending(x = |
| | 55 | | } |
| | 56 | |
|
| | 57 | | public static IEnumerable<DrawingModel> SortByUserScoreAscending(this IEnumerable<DrawingModel> drawings) |
| | 58 | | { |
| 52 | 59 | | return drawings.Where(x => x.VotesPopular > 0) |
| 44 | 60 | | .OrderBy(x => x.ScorePopular) |
| 44 | 61 | | .ThenBy(x => x.VotesPopular) |
| 46 | 62 | | .ThenBy(x => x.ScoreCritic); |
| | 63 | | } |
| | 64 | |
|
| | 65 | | public static IEnumerable<DrawingModel> SortByUserScoreDescending(this IEnumerable<DrawingModel> drawings) |
| | 66 | | { |
| 52 | 67 | | return drawings.Where(x => x.VotesPopular > 0) |
| 44 | 68 | | .OrderByDescending(x => x.ScorePopular) |
| 44 | 69 | | .ThenByDescending(x => x.VotesPopular) |
| 46 | 70 | | .ThenByDescending(x => x.ScoreCritic); |
| | 71 | | } |
| | 72 | |
|
| | 73 | | public static IEnumerable<DrawingModel> SortByFastest(this IEnumerable<DrawingModel> drawings) |
| | 74 | | { |
| 35 | 75 | | return drawings.OrderBy(x => x.Time); |
| | 76 | | } |
| | 77 | |
|
| | 78 | | public static IEnumerable<DrawingModel> SortBySlowest(this IEnumerable<DrawingModel> drawings) |
| | 79 | | { |
| 35 | 80 | | return drawings.OrderByDescending(x => x.Time); |
| | 81 | | } |
| | 82 | |
|
| | 83 | | public static IEnumerable<DrawingModel> SortByPopularity(this IEnumerable<DrawingModel> drawings) |
| | 84 | | { |
| 103 | 85 | | return drawings.OrderByDescending(x => x.Popularity); |
| | 86 | | } |
| | 87 | | } |