| | 1 | | using MRA.DTO.Enums; |
| | 2 | | using MRA.DTO.Enums.Drawing; |
| | 3 | | using MRA.DTO.Enums.DrawingFilter; |
| | 4 | | using MRA.Infrastructure.Enums; |
| | 5 | | using System.Text.Json.Serialization; |
| | 6 | |
|
| | 7 | | namespace MRA.DTO.ViewModels.Art; |
| | 8 | |
|
| | 9 | | public class DrawingFilter |
| | 10 | | { |
| | 11 | | public const string PRODUCT_NONE = "none"; |
| | 12 | | public const string CHARACTER_NONE = "none"; |
| | 13 | | public const string MODEL_NONE = "none"; |
| | 14 | |
|
| | 15 | | [JsonConverter(typeof(EnumStringJsonConverter<DrawingTypes>))] |
| 156 | 16 | | public DrawingTypes Type { get; set; } |
| | 17 | |
|
| 154 | 18 | | public DrawingProductTypes ProductType { get; set; } |
| | 19 | |
|
| 155 | 20 | | public string ProductName { get; set; } |
| | 21 | |
|
| 130 | 22 | | public string ModelName { get; set; } |
| | 23 | |
|
| 130 | 24 | | public string CharacterName { get; set; } |
| | 25 | |
|
| 149 | 26 | | public string Collection { get; set; } |
| | 27 | |
|
| 128 | 28 | | public DrawingSoftwares Software { get; set; } |
| | 29 | |
|
| 128 | 30 | | public DrawingPaperSizes Paper { get; set; } |
| | 31 | |
|
| | 32 | | [JsonConverter(typeof(EnumStringJsonConverter<DrawingFilterSortBy>))] |
| 200 | 33 | | public DrawingFilterSortBy Sortby { get; set; } |
| | 34 | |
|
| 128 | 35 | | public bool? Spotify { get; set; } |
| | 36 | |
|
| 158 | 37 | | public string TextQuery { get; set; } |
| 64 | 38 | | public IEnumerable<string> Tags { get { return TextQuery.Split(" ").Select(x => x.ToLower()); } } |
| | 39 | |
|
| 125 | 40 | | public bool Favorites { get; set; } |
| | 41 | |
|
| 62 | 42 | | public int PageSize { get; set; } |
| | 43 | |
|
| 31 | 44 | | public int PageNumber { get; set; } |
| | 45 | |
|
| 189 | 46 | | public bool OnlyVisible { get; set; } |
| | 47 | |
|
| 31 | 48 | | public string CacheKey { get => $"filter_{Type}_{ProductType}_{ProductName}_{ModelName}_{CharacterName}_{Collection} |
| | 49 | |
|
| | 50 | |
|
| | 51 | | public static DrawingFilter GetModelNoFilters() => |
| 62 | 52 | | new DrawingFilter() |
| 62 | 53 | | { |
| 62 | 54 | | Sortby = EnumExtensions.GetDefaultValue<DrawingFilterSortBy>(), |
| 62 | 55 | | TextQuery = "", |
| 62 | 56 | | Type = EnumExtensions.GetDefaultValue<DrawingTypes>(), |
| 62 | 57 | | ProductType = EnumExtensions.GetDefaultValue<DrawingProductTypes>(), |
| 62 | 58 | | ProductName = "", |
| 62 | 59 | | Collection = "", |
| 62 | 60 | | CharacterName = "", |
| 62 | 61 | | ModelName = "", |
| 62 | 62 | | Software = EnumExtensions.GetDefaultValue<DrawingSoftwares>(), |
| 62 | 63 | | Paper = EnumExtensions.GetDefaultValue<DrawingPaperSizes>(), |
| 62 | 64 | | Favorites = false, |
| 62 | 65 | | Spotify = null, |
| 62 | 66 | | OnlyVisible = false, |
| 62 | 67 | | }; |
| | 68 | |
|
| | 69 | | public bool OnlyFilterCollection() |
| | 70 | | { |
| 31 | 71 | | var noFilters = GetModelNoFilters(); |
| | 72 | |
|
| 31 | 73 | | return |
| 31 | 74 | | Sortby == noFilters.Sortby && |
| 31 | 75 | | TextQuery == noFilters.TextQuery && |
| 31 | 76 | | Type == noFilters.Type && |
| 31 | 77 | | ProductType == noFilters.ProductType && |
| 31 | 78 | | ProductName == noFilters.ProductName && |
| 31 | 79 | | Collection != noFilters.Collection && |
| 31 | 80 | | CharacterName == noFilters.CharacterName && |
| 31 | 81 | | ModelName == noFilters.ModelName && |
| 31 | 82 | | Software == noFilters.Software && |
| 31 | 83 | | Paper == noFilters.Paper; |
| | 84 | | } |
| | 85 | | } |