From 5eb99a66a28ca9b5002b343d07fc625dd05e133e Mon Sep 17 00:00:00 2001 From: Dhiogo Acioli Date: Sat, 13 Jul 2024 20:44:30 +0200 Subject: [PATCH] sync code with SD 2 --- MM.API/Core/ApiStartup.cs | 7 +- MM.API/Core/IsolatedFunctionHelper.cs | 2 +- MM.API/Functions/CacheFunction.cs | 217 ++-- MM.API/Functions/ExternalFunction.cs | 31 +- MM.API/Functions/InviteFunction.cs | 8 +- MM.API/Functions/LoginFunction.cs | 7 +- MM.API/Functions/PaddleFunction.cs | 13 +- MM.API/Functions/PrincipalFunction.cs | 30 +- MM.API/Functions/ProfileFunction.cs | 58 +- MM.API/Functions/SendgridFunction.cs | 4 +- MM.API/Functions/SupportFunction.cs | 53 +- MM.API/MM.API.csproj | 12 +- MM.API/Program.cs | 4 +- .../Core/CosmosRepositoryExtensions.cs | 34 + MM.API/Repository/Core/IRepository.cs | 20 - MM.API/Repository/CosmosCacheRepository.cs | 15 +- MM.API/Repository/CosmosEmailRepository.cs | 16 +- MM.API/Repository/CosmosLogRepository.cs | 5 +- MM.API/Repository/CosmosRepository.cs | 61 +- MM.Shared/Core/CosmosDocument.cs | 9 +- MM.Shared/Core/Helper/CustomAttribute.cs | 2 +- MM.Shared/Core/Helper/EnumHelper.cs | 23 +- MM.Shared/Core/Helper/ImageHelper.cs | 2 +- MM.Shared/Core/Helper/SubscriptionHelper.cs | 2 +- MM.Shared/Core/Models/CacheDocument.cs | 2 +- MM.Shared/Core/Models/LogDocument.cs | 2 +- MM.Shared/Core/Models/MainDocument.cs | 10 +- MM.Shared/Enums/ChineseZodiac.cs | 13 - MM.Shared/Enums/Country.cs | 855 ++++++++++++---- MM.Shared/Enums/Language.cs | 647 ++++++++---- .../Enums/Resources/Language.Designer.cs | 387 ------- MM.Shared/Enums/Resources/Language.es.resx | 228 ----- MM.Shared/Enums/Resources/Language.pt.resx | 228 ----- MM.Shared/Enums/Resources/Language.resx | 228 ----- MM.Shared/MM.Shared.csproj | 13 +- MM.Shared/Models/Auth/ClienteLogin.cs | 1 - MM.Shared/Models/Auth/ClientePrincipal.cs | 1 - MM.Shared/Models/GoogleJson.cs | 82 ++ .../Models/{JavascriptVM.cs => HereJson.cs} | 14 +- MM.Shared/Models/Profile/ProfileModel.cs | 25 +- .../Models/Profile/ProfilePreferenceModel.cs | 45 +- .../ProfileLifestyleModel.Designer.cs | 2 +- .../Resources/ProfileLifestyleModel.es.resx | 6 +- .../Resources/ProfileLifestyleModel.pt.resx | 6 +- .../Resources/ProfileLifestyleModel.resx | 2 +- MM.Shared/Models/Support/EmailDocument.cs | 2 +- MM.Shared/Models/Support/TicketModel.cs | 28 +- MM.Shared/Models/Support/TicketVoteModel.cs | 39 - MM.Shared/Models/Support/UpdateModel.cs | 7 +- MM.WEB/Core/AffinityCore.cs | 202 ++-- MM.WEB/Core/Api/ApiCosmos.cs | 2 +- MM.WEB/Core/Api/CacheSettings.cs | 2 +- MM.WEB/Core/AppStateStatic.cs | 5 +- MM.WEB/Core/PopupHelper.cs | 53 +- MM.WEB/MM.WEB.csproj | 27 +- MM.WEB/Modules/Administrator/Index.razor | 3 - MM.WEB/Modules/Auth/ProfilePrincipal.razor | 2 +- MM.WEB/Modules/Index.razor | 338 +----- .../Components/CardCompatibility.razor | 20 +- .../Profile/Components/ItemDataProfile.razor | 86 +- .../Profile/Components/MyRelationships.razor | 42 +- .../Profile/Components/PopupProfile.razor | 6 +- .../Profile/Components/ProfileReport.razor | 2 +- MM.WEB/Modules/Profile/Core/DataHelper.cs | 965 ++++++++++++++---- MM.WEB/Modules/Profile/Core/MapaApi.cs | 15 +- MM.WEB/Modules/Profile/Core/ProfileApi.cs | 12 +- MM.WEB/Modules/Profile/Profile.razor | 308 ++++++ MM.WEB/Modules/Profile/ProfileData.razor | 396 +++---- MM.WEB/Modules/Profile/ProfileData.razor.cs | 76 +- .../Modules/Profile/ProfilePreference.razor | 52 +- MM.WEB/Modules/Shared/Field/Birthdate.razor | 90 +- MM.WEB/Modules/Shared/Field/FieldSelect.razor | 5 +- .../Modules/Shared/Field/FieldSelect.razor.cs | 14 +- .../Shared/Field/ProfileDataSelect.razor | 12 +- .../Components/SubscriptionPopup.razor | 20 +- .../Component/AnnouncementComponent.razor | 23 +- .../Support/Component/DownloadComponent.razor | 6 +- .../Support/Component/FeedbackComponent.razor | 22 +- MM.WEB/Modules/Support/Core/TicketVoteApi.cs | 31 - MM.WEB/Program.cs | 3 +- MM.WEB/Resources/BuildDate.txt | 2 +- .../Resources/GlobalTranslations.Designer.cs | 20 +- MM.WEB/Resources/GlobalTranslations.es.resx | 5 +- MM.WEB/Resources/GlobalTranslations.pt.resx | 5 +- MM.WEB/Resources/GlobalTranslations.resx | 8 +- MM.WEB/Shared/HeadLayout.razor | 39 +- MM.WEB/Shared/HeaderComponent.razor | 33 + MM.WEB/Shared/MainLayout.razor | 51 +- MM.WEB/Shared/SettingsPopup.razor | 23 + MM.WEB/_Imports.razor | 1 - MM.WEB/wwwroot/appsettings.json | 2 +- MM.WEB/wwwroot/css/custom_app.css | 4 +- MM.WEB/wwwroot/css/custom_app.min.css | 2 +- MM.WEB/wwwroot/dev-env/me.json | 2 +- MM.WEB/wwwroot/index.html | 3 +- MM.WEB/wwwroot/js/paddle.js | 2 +- MM.WEB/wwwroot/js/util.js | 7 +- MM.WEB/wwwroot/manifest.webmanifest | 5 - 98 files changed, 3364 insertions(+), 3198 deletions(-) create mode 100644 MM.API/Repository/Core/CosmosRepositoryExtensions.cs delete mode 100644 MM.API/Repository/Core/IRepository.cs delete mode 100644 MM.Shared/Enums/ChineseZodiac.cs delete mode 100644 MM.Shared/Enums/Resources/Language.Designer.cs delete mode 100644 MM.Shared/Enums/Resources/Language.es.resx delete mode 100644 MM.Shared/Enums/Resources/Language.pt.resx delete mode 100644 MM.Shared/Enums/Resources/Language.resx create mode 100644 MM.Shared/Models/GoogleJson.cs rename MM.Shared/Models/{JavascriptVM.cs => HereJson.cs} (57%) delete mode 100644 MM.Shared/Models/Support/TicketVoteModel.cs create mode 100644 MM.WEB/Modules/Profile/Profile.razor delete mode 100644 MM.WEB/Modules/Support/Core/TicketVoteApi.cs create mode 100644 MM.WEB/Shared/HeaderComponent.razor create mode 100644 MM.WEB/Shared/SettingsPopup.razor diff --git a/MM.API/Core/ApiStartup.cs b/MM.API/Core/ApiStartup.cs index 49be328..0f3d4c1 100644 --- a/MM.API/Core/ApiStartup.cs +++ b/MM.API/Core/ApiStartup.cs @@ -5,10 +5,12 @@ namespace MM.API.Core public static class ApiStartup { private static readonly HttpClient _httpClient = new(); + private static readonly HttpClient _httpClientPaddle = new(); private static CosmosClient _cosmosClient = default!; public static HttpClient HttpClient => _httpClient; + public static HttpClient HttpClientPaddle => _httpClientPaddle; public static CosmosClient CosmosClient => _cosmosClient; public static void Startup(string conn) @@ -18,7 +20,10 @@ public static void Startup(string conn) SerializerOptions = new CosmosSerializationOptions() { PropertyNamingPolicy = CosmosPropertyNamingPolicy.CamelCase - } + }, + + //https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/sdk-connection-modes + //ConnectionMode = ConnectionMode.Gateway // ConnectionMode.Direct is the default }); } } diff --git a/MM.API/Core/IsolatedFunctionHelper.cs b/MM.API/Core/IsolatedFunctionHelper.cs index d7a80d4..cee19e4 100644 --- a/MM.API/Core/IsolatedFunctionHelper.cs +++ b/MM.API/Core/IsolatedFunctionHelper.cs @@ -29,7 +29,7 @@ public static class IsolatedFunctionHelper if (model is ProtectedMainDocument prot) { - prot.Initialize(userId, userId); + prot.Initialize(userId); } else if (model is PrivateMainDocument priv) { diff --git a/MM.API/Functions/CacheFunction.cs b/MM.API/Functions/CacheFunction.cs index b159749..a7a953d 100644 --- a/MM.API/Functions/CacheFunction.cs +++ b/MM.API/Functions/CacheFunction.cs @@ -15,38 +15,37 @@ public class CacheFunction(CosmosCacheRepository cacheRepo) // if (model == null) // { - // using var http = new HttpClient(); - // var obj = await http.GetNewsByFlixter(cancellationToken); + // var obj = await ApiStartup.HttpClient.GetNewsByFlixter(cancellationToken); // if (obj == null) return null; - // //compact - - // var compactModels = new NewsModel(); - - // foreach (var item in obj.data?.newsStories.Take(8) ?? Enumerable.Empty()) + // if (mode == "compact") // { - // if (item == null) continue; - // compactModels.Items.Add(new Shared.Models.News.Item(item.id, item.title, item.mainImage?.url, item.link)); - // } - - // var compactResult = await cacheRepo.Add(new FlixsterCache(compactModels, "lastnews_compact"), cancellationToken); + // var compactModels = new NewsModel(); - // //full + // foreach (var item in obj.data?.newsStories.Take(8) ?? []) + // { + // if (item == null) continue; + // compactModels.Items.Add(new Shared.Models.News.Item(item.id, item.title, item.mainImage?.url, item.link)); + // } - // var fullModels = new NewsModel(); + // var compactResult = await cacheRepo.CreateItemAsync(new FlixsterCache(compactModels, "lastnews_compact"), cancellationToken); - // foreach (var item in obj.data?.newsStories ?? Enumerable.Empty()) - // { - // if (item == null) continue; - // fullModels.Items.Add(new Shared.Models.News.Item(item.id, item.title, item.mainImage?.url, item.link)); + // return compactResult?.Data; // } + // else + // { + // var fullModels = new NewsModel(); - // var fullResult = await cacheRepo.Add(new FlixsterCache(fullModels, "lastnews_full"), cancellationToken); + // foreach (var item in obj.data?.newsStories ?? Enumerable.Empty()) + // { + // if (item == null) continue; + // fullModels.Items.Add(new Shared.Models.News.Item(item.id, item.title, item.mainImage?.url, item.link)); + // } + + // var fullResult = await cacheRepo.CreateItemAsync(new FlixsterCache(fullModels, "lastnews_full"), cancellationToken); - // if (mode == "compact") - // return compactResult?.Data; - // else // return fullResult?.Data; + // } // } // else // { @@ -73,38 +72,37 @@ public class CacheFunction(CosmosCacheRepository cacheRepo) // if (model == null) // { - // using var http = new HttpClient(); - // var obj = await http.GetTrailersByYoutubeSearch(cancellationToken); + // var obj = await ApiStartup.HttpClient.GetTrailersByYoutubeSearch(cancellationToken); // if (obj == null) return null; - // //compact - - // var compactModels = new TrailerModel(); - - // foreach (var item in obj.contents.Take(8).Select(s => s.video)) + // if (mode == "compact") // { - // if (item == null) continue; - // compactModels.Items.Add(new Shared.Models.Trailers.Item(item.videoId, item.title, item.thumbnails[0].url)); - // } - - // var compactResult = await cacheRepo.Add(new YoutubeCache(compactModels, "lasttrailers_compact"), cancellationToken); + // var compactModels = new TrailerModel(); - // //full + // foreach (var item in obj.contents.Take(8).Select(s => s.video)) + // { + // if (item == null) continue; + // compactModels.Items.Add(new Shared.Models.Trailers.Item(item.videoId, item.title, item.thumbnails[0].url)); + // } - // var fullModels = new TrailerModel(); + // var compactResult = await cacheRepo.CreateItemAsync(new YoutubeCache(compactModels, "lasttrailers_compact"), cancellationToken); - // foreach (var item in obj.contents.Select(s => s.video)) - // { - // if (item == null) continue; - // fullModels.Items.Add(new Shared.Models.Trailers.Item(item.videoId, item.title, item.thumbnails[2].url)); + // return compactResult?.Data; // } + // else + // { + // var fullModels = new TrailerModel(); - // var fullResult = await cacheRepo.Add(new YoutubeCache(fullModels, "lasttrailers_full"), cancellationToken); + // foreach (var item in obj.contents.Select(s => s.video)) + // { + // if (item == null) continue; + // fullModels.Items.Add(new Shared.Models.Trailers.Item(item.videoId, item.title, item.thumbnails[2].url)); + // } + + // var fullResult = await cacheRepo.CreateItemAsync(new YoutubeCache(fullModels, "lasttrailers_full"), cancellationToken); - // if (mode == "compact") - // return compactResult?.Data; - // else // return fullResult?.Data; + // } // } // else // { @@ -135,34 +133,34 @@ public class CacheFunction(CosmosCacheRepository cacheRepo) // var obj = scraping.GetMovieData(); // if (obj == null) return null; - // //compact - - // var compactModels = new MostPopularData() { ErrorMessage = obj.ErrorMessage }; - - // foreach (var item in obj.Items.Take(10)) + // if (mode == "compact") // { - // if (item == null) continue; - // compactModels.Items.Add(item); - // } - - // var compactResult = await cacheRepo.Add(new MostPopularDataCache(compactModels, "popularmovies_compact"), cancellationToken); + // var compactModels = new MostPopularData() { ErrorMessage = obj.ErrorMessage }; - // //full + // foreach (var item in obj.Items.Take(10)) + // { + // if (item == null) continue; + // compactModels.Items.Add(item); + // } - // var fullModels = new MostPopularData() { ErrorMessage = obj.ErrorMessage }; + // var compactResult = await cacheRepo.CreateItemAsync(new MostPopularDataCache(compactModels, "popularmovies_compact"), cancellationToken); - // foreach (var item in obj.Items) - // { - // if (item == null) continue; - // fullModels.Items.Add(item); + // return compactResult?.Data; // } + // else + // { + // var fullModels = new MostPopularData() { ErrorMessage = obj.ErrorMessage }; - // var fullResult = await cacheRepo.Add(new MostPopularDataCache(fullModels, "popularmovies_full"), cancellationToken); + // foreach (var item in obj.Items) + // { + // if (item == null) continue; + // fullModels.Items.Add(item); + // } + + // var fullResult = await cacheRepo.CreateItemAsync(new MostPopularDataCache(fullModels, "popularmovies_full"), cancellationToken); - // if (mode == "compact") - // return compactResult?.Data; - // else // return fullResult?.Data; + // } // } // else // { @@ -188,12 +186,11 @@ public class CacheFunction(CosmosCacheRepository cacheRepo) // if (model == null) // { - // using var http = new HttpClient(); // var scraping = new ScrapingPopular(); // var obj = scraping.GetTvData(); // if (obj == null) return null; - // model = await cacheRepo.Add(new MostPopularDataCache(obj, "populartvs"), cancellationToken); + // model = await cacheRepo.CreateItemAsync(new MostPopularDataCache(obj, "populartvs"), cancellationToken); // } // return model?.Data; @@ -227,25 +224,21 @@ public class CacheFunction(CosmosCacheRepository cacheRepo) // var obj = scraping.GetMovieData(id, tmdb_rating, title, release_date.Year.ToString()); // if (obj == null) return null; - // if (release_date.Date == DateTime.MinValue.Date || release_date.Date == DateTime.MaxValue.Date) + // if (release_date.Date == DateTime.MinValue.Date || release_date.Date == DateTime.MaxValue.Date) //invalid date // { - // //invalid date - // model = await cacheRepo.Add(new RatingsCache(id, obj, ttlCache.one_day), cancellationToken); + // model = await cacheRepo.CreateItemAsync(new RatingsCache(id, obj, ttlCache.one_day), cancellationToken); // } - // else if (release_date > DateTime.Now.AddMonths(-1)) + // else if (release_date > DateTime.Now.AddDays(-7)) // < 1 week launch // { - // // < 1 month launch - // model = await cacheRepo.Add(new RatingsCache(id, obj, ttlCache.one_week), cancellationToken); + // model = await cacheRepo.CreateItemAsync(new RatingsCache(id, obj, ttlCache.one_day), cancellationToken); // } - // else if (release_date > DateTime.Now.AddMonths(-6)) + // else if (release_date > DateTime.Now.AddMonths(-1)) // < 1 month launch // { - // // < 6 month launch - // model = await cacheRepo.Add(new RatingsCache(id, obj, ttlCache.one_month), cancellationToken); + // model = await cacheRepo.CreateItemAsync(new RatingsCache(id, obj, ttlCache.one_week), cancellationToken); // } - // else + // else // > 1 month launch // { - // // > 6 month launch - // model = await cacheRepo.Add(new RatingsCache(id, obj, ttlCache.one_year), cancellationToken); + // model = await cacheRepo.CreateItemAsync(new RatingsCache(id, obj, ttlCache.one_month), cancellationToken); // } // } @@ -280,25 +273,21 @@ public class CacheFunction(CosmosCacheRepository cacheRepo) // var obj = scraping.GetShowData(id, tmdb_rating, title, release_date.Year.ToString()); // if (obj == null) return null; - // if (release_date.Date == DateTime.MinValue.Date || release_date.Date == DateTime.MaxValue.Date) + // if (release_date.Date == DateTime.MinValue.Date || release_date.Date == DateTime.MaxValue.Date) //invalid date // { - // //invalid date - // model = await cacheRepo.Add(new RatingsCache(id, obj, ttlCache.one_day), cancellationToken); + // model = await cacheRepo.CreateItemAsync(new RatingsCache(id, obj, ttlCache.one_day), cancellationToken); // } - // else if (release_date > DateTime.Now.AddMonths(-1)) + // else if (release_date > DateTime.Now.AddDays(-7)) // < 1 week launch // { - // // < 1 month launch - // model = await cacheRepo.Add(new RatingsCache(id, obj, ttlCache.one_week), cancellationToken); + // model = await cacheRepo.CreateItemAsync(new RatingsCache(id, obj, ttlCache.one_day), cancellationToken); // } - // else if (release_date > DateTime.Now.AddMonths(-6)) + // else if (release_date > DateTime.Now.AddMonths(-1)) // < 1 month launch // { - // // < 6 month launch - // model = await cacheRepo.Add(new RatingsCache(id, obj, ttlCache.one_month), cancellationToken); + // model = await cacheRepo.CreateItemAsync(new RatingsCache(id, obj, ttlCache.one_week), cancellationToken); // } - // else + // else // > 1 month launch // { - // // > 6 month launch - // model = await cacheRepo.Add(new RatingsCache(id, obj, ttlCache.one_year), cancellationToken); + // model = await cacheRepo.CreateItemAsync(new RatingsCache(id, obj, ttlCache.one_month), cancellationToken); // } // } @@ -327,37 +316,32 @@ public class CacheFunction(CosmosCacheRepository cacheRepo) // if (model == null) // { - // using var http = new HttpClient(); - // var obj = await http.GetReviewsByImdb8(id, cancellationToken); + // var obj = await ApiStartup.HttpClient.GetReviewsByImdb8(id, cancellationToken); // if (obj == null) return null; // var newModel = new ReviewModel(); - // foreach (var item in obj?.data?.title?.metacritic?.reviews?.edges ?? []) + // foreach (var item in obj.data?.title?.metacritic?.reviews?.edges ?? []) // { // if (item == null) continue; // newModel.Items.Add(new Shared.Models.Reviews.Item(item.node?.site, item.node?.url, item.node?.reviewer, item.node?.score, item.node?.quote?.value)); // } - // if (release_date.Date == DateTime.MinValue.Date || release_date.Date == DateTime.MaxValue.Date) + // if (release_date.Date == DateTime.MinValue.Date || release_date.Date == DateTime.MaxValue.Date) //invalid date // { - // //invalid date - // model = await cacheRepo.Add(new MetaCriticCache(newModel, $"review_{id}", ttlCache.one_day), cancellationToken); + // model = await cacheRepo.CreateItemAsync(new MetaCriticCache(newModel, $"review_{id}", ttlCache.one_day), cancellationToken); // } - // else if (release_date > DateTime.Now.AddMonths(-1)) + // else if (release_date > DateTime.Now.AddDays(-7)) // < 1 week launch // { - // // < 1 month launch - // model = await cacheRepo.Add(new MetaCriticCache(newModel, $"review_{id}", ttlCache.one_week), cancellationToken); + // model = await cacheRepo.CreateItemAsync(new MetaCriticCache(newModel, $"review_{id}", ttlCache.one_day), cancellationToken); // } - // else if (release_date > DateTime.Now.AddMonths(-6)) + // else if (release_date > DateTime.Now.AddMonths(-1)) // < 1 month launch // { - // // < 6 month launch - // model = await cacheRepo.Add(new MetaCriticCache(newModel, $"review_{id}", ttlCache.one_month), cancellationToken); + // model = await cacheRepo.CreateItemAsync(new MetaCriticCache(newModel, $"review_{id}", ttlCache.one_week), cancellationToken); // } - // else + // else // > 1 month launch // { - // // > 6 month launch - // model = await cacheRepo.Add(new MetaCriticCache(newModel, $"review_{id}", ttlCache.one_year), cancellationToken); + // model = await cacheRepo.CreateItemAsync(new MetaCriticCache(newModel, $"review_{id}", ttlCache.one_month), cancellationToken); // } // } @@ -391,9 +375,8 @@ public class CacheFunction(CosmosCacheRepository cacheRepo) // if (model == null) // { - // using var http = new HttpClient(); // var url = $"https://internal-prod.apigee.fandom.net/v1/xapi/composer/metacritic/pages/shows-critic-reviews/{title}/web?filter=all&sort=score&apiKey=1MOZgmNFxvmljaQR1X9KAij9Mo4xAY3u"; - // var obj = await http.Get(url, cancellationToken); + // var obj = await ApiStartup.HttpClient.Get(url, cancellationToken); // if (obj == null) return null; // if (obj.meta?.title == "undefined critic reviews") return null; @@ -405,25 +388,21 @@ public class CacheFunction(CosmosCacheRepository cacheRepo) // newModel.Items.Add(new Shared.Models.Reviews.Item(item.publicationName, item.url, item.author, item.score, item.quote)); // } - // if (release_date.Date == DateTime.MinValue.Date || release_date.Date == DateTime.MaxValue.Date) + // if (release_date.Date == DateTime.MinValue.Date || release_date.Date == DateTime.MaxValue.Date) //invalid date // { - // //invalid date - // model = await cacheRepo.Add(new MetaCriticCache(newModel, $"review_{id}", ttlCache.one_day), cancellationToken); + // model = await cacheRepo.CreateItemAsync(new MetaCriticCache(newModel, $"review_{id}", ttlCache.one_day), cancellationToken); // } - // else if (release_date > DateTime.Now.AddMonths(-1)) + // else if (release_date > DateTime.Now.AddDays(-7)) // < 1 week launch // { - // // < 1 month launch - // model = await cacheRepo.Add(new MetaCriticCache(newModel, $"review_{id}", ttlCache.one_week), cancellationToken); + // model = await cacheRepo.CreateItemAsync(new MetaCriticCache(newModel, $"review_{id}", ttlCache.one_day), cancellationToken); // } - // else if (release_date > DateTime.Now.AddMonths(-6)) + // else if (release_date > DateTime.Now.AddMonths(-1)) // < 1 month launch // { - // // < 6 month launch - // model = await cacheRepo.Add(new MetaCriticCache(newModel, $"review_{id}", ttlCache.one_month), cancellationToken); + // model = await cacheRepo.CreateItemAsync(new MetaCriticCache(newModel, $"review_{id}", ttlCache.one_week), cancellationToken); // } - // else + // else // > 1 month launch // { - // // > 6 month launch - // model = await cacheRepo.Add(new MetaCriticCache(newModel, $"review_{id}", ttlCache.one_year), cancellationToken); + // model = await cacheRepo.CreateItemAsync(new MetaCriticCache(newModel, $"review_{id}", ttlCache.one_month), cancellationToken); // } // } diff --git a/MM.API/Functions/ExternalFunction.cs b/MM.API/Functions/ExternalFunction.cs index 2ceece8..899be65 100644 --- a/MM.API/Functions/ExternalFunction.cs +++ b/MM.API/Functions/ExternalFunction.cs @@ -4,24 +4,37 @@ namespace VerusDate.Api.Function { - public class ExternalFunction + public class ExternalFunction(IConfiguration config) { - public string HereApiKey { get; set; } + public string HereApiKey { get; set; } = config.GetValue("Here_ApiKey"); + public string GoogleApiKey { get; set; } = config.GetValue("Google_ApiKey"); - public ExternalFunction(IConfiguration config) + [Function("GetLocationHere")] + public async Task GetLocationHere( + [HttpTrigger(AuthorizationLevel.Function, Method.GET, Route = "location/here/{latitude}/{longitude}")] HttpRequestData req, + string latitude, string longitude, CancellationToken cancellationToken) { - HereApiKey = config.GetValue("Here_ApiKey"); + try + { + using var http = new HttpClient(); + return await http.Get($"https://browse.search.hereapi.com/v1/browse?at={latitude},{longitude}&lang=en-US&limit=1&apiKey={HereApiKey}", cancellationToken); + } + catch (Exception ex) + { + req.ProcessException(ex); + throw new UnhandledException(ex.BuildException()); + } } - [Function("ExternalGetLocation")] - public async Task GetLocation( - [HttpTrigger(AuthorizationLevel.Function, Method.GET, Route = "External/GetLocation/{latitude}/{longitude}")] HttpRequestData req, - string latitude, string longitude, CancellationToken cancellationToken) + [Function("GetLocationGoogle")] + public async Task GetLocationGoogle( + [HttpTrigger(AuthorizationLevel.Function, Method.GET, Route = "location/google/{latitude}/{longitude}")] HttpRequestData req, + string latitude, string longitude, CancellationToken cancellationToken) { try { using var http = new HttpClient(); - return await http.Get($"https://browse.search.hereapi.com/v1/browse?at={latitude},{longitude}&lang=en-US&limit=1&apiKey={HereApiKey}", cancellationToken); + return await http.Get($"https://maps.googleapis.com/maps/api/geocode/json?latlng={latitude},{longitude}&language=en&key={GoogleApiKey}", cancellationToken); } catch (Exception ex) { diff --git a/MM.API/Functions/InviteFunction.cs b/MM.API/Functions/InviteFunction.cs index b91d311..fe21aba 100644 --- a/MM.API/Functions/InviteFunction.cs +++ b/MM.API/Functions/InviteFunction.cs @@ -1,16 +1,14 @@ -using Microsoft.Azure.Cosmos; using Microsoft.Azure.Functions.Worker; using Microsoft.Azure.Functions.Worker.Http; -using MM.API.Repository.Core; using MM.Shared.Models.Profile; namespace VerusDate.Api.Function { public class InviteFunction { - private readonly IRepository _repo; + private readonly CosmosRepository _repo; - public InviteFunction(IRepository repo) + public InviteFunction(CosmosRepository repo) { _repo = repo; } @@ -23,7 +21,7 @@ public InviteFunction(IRepository repo) { var userId = req.GetUserId(); - return await _repo.Get(DocumentType.Invite + ":" + userId, new PartitionKey(userId), cancellationToken); + return await _repo.Get(DocumentType.Invite, userId, cancellationToken); } catch (Exception ex) { diff --git a/MM.API/Functions/LoginFunction.cs b/MM.API/Functions/LoginFunction.cs index 77a6747..162bad3 100644 --- a/MM.API/Functions/LoginFunction.cs +++ b/MM.API/Functions/LoginFunction.cs @@ -1,12 +1,11 @@ using Microsoft.Azure.Cosmos; using Microsoft.Azure.Functions.Worker; using Microsoft.Azure.Functions.Worker.Http; -using MM.API.Repository.Core; using MM.Shared.Models.Auth; namespace MM.API.Functions { - public class LoginFunction(IRepository repo) + public class LoginFunction(CosmosRepository repo) { //[OpenApiOperation("LoginAdd", "Azure (Cosmos DB)")] //[OpenApiResponseWithBody(HttpStatusCode.OK, "application/json", typeof(void))] @@ -20,7 +19,7 @@ public async Task Add( if (platform.Empty()) platform = "webapp"; var userId = req.GetUserId(); if (string.IsNullOrEmpty(userId)) throw new InvalidOperationException("unauthenticated user"); - var login = await repo.Get(DocumentType.Login + ":" + userId, new PartitionKey(userId), cancellationToken); + var login = await repo.Get(DocumentType.Login, userId, cancellationToken); if (login == null) { @@ -33,7 +32,7 @@ public async Task Add( { if (Array.Exists(login.Platforms, a => a == platform)) { - await repo.PatchItem(nameof(DocumentType.Login) + ":" + userId, new PartitionKey(userId), + await repo.PatchItem(DocumentType.Login, userId, [ PatchOperation.Add("/logins/-", DateTimeOffset.Now), ], cancellationToken); diff --git a/MM.API/Functions/PaddleFunction.cs b/MM.API/Functions/PaddleFunction.cs index 52367dd..de58554 100644 --- a/MM.API/Functions/PaddleFunction.cs +++ b/MM.API/Functions/PaddleFunction.cs @@ -1,7 +1,6 @@ using Microsoft.Azure.Functions.Worker; using Microsoft.Azure.Functions.Worker.Http; using Microsoft.Extensions.Configuration; -using MM.API.Repository.Core; using MM.Shared.Models.Auth; using MM.Shared.Models.Subscription; using System.Net.Http.Headers; @@ -9,7 +8,7 @@ namespace MM.API.Functions { - public class PaddleFunction(IRepository repo, IConfiguration configuration) + public class PaddleFunction(CosmosRepository repo, IConfiguration configuration) { [Function("GetSubscription")] public async Task GetSubscription( @@ -22,11 +21,11 @@ public class PaddleFunction(IRepository repo, IConfiguration configuration) var endpoint = configuration.GetValue("Paddle_Endpoint"); var key = configuration.GetValue("Paddle_Key"); - ApiStartup.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", key); + ApiStartup.HttpClientPaddle.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", key); using var request = new HttpRequestMessage(HttpMethod.Get, $"{endpoint}subscriptions/{id}"); - var response = await ApiStartup.HttpClient.SendAsync(request, cancellationToken); + var response = await ApiStartup.HttpClientPaddle.SendAsync(request, cancellationToken); if (!response.IsSuccessStatusCode) throw new NotificationException(response.ReasonPhrase); @@ -50,11 +49,11 @@ public class PaddleFunction(IRepository repo, IConfiguration configuration) var endpoint = configuration.GetValue("Paddle_Endpoint"); var key = configuration.GetValue("Paddle_Key"); - ApiStartup.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", key); + ApiStartup.HttpClientPaddle.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", key); using var request = new HttpRequestMessage(HttpMethod.Get, $"{endpoint}subscriptions/{id}/update-payment-method-transaction"); - var response = await ApiStartup.HttpClient.SendAsync(request, cancellationToken); + var response = await ApiStartup.HttpClientPaddle.SendAsync(request, cancellationToken); if (!response.IsSuccessStatusCode) throw new NotificationException(response.ReasonPhrase); @@ -80,7 +79,7 @@ public async Task PostSubscription( var body = await req.GetPublicBody(cancellationToken) ?? throw new NotificationException("body null"); if (body.data == null) throw new NotificationException("body.data null"); - var result = await repo.Query(x => x.ClientePaddle != null && x.ClientePaddle.CustomerId == body.data.customer_id, null, DocumentType.Principal, cancellationToken) ?? throw new NotificationException("ClientePrincipal null"); + var result = await repo.Query(x => x.ClientePaddle != null && x.ClientePaddle.CustomerId == body.data.customer_id, DocumentType.Principal, cancellationToken) ?? throw new NotificationException("ClientePrincipal null"); var client = result.FirstOrDefault() ?? throw new NotificationException("client null"); if (client.ClientePaddle == null) throw new NotificationException("client.ClientePaddle null"); diff --git a/MM.API/Functions/PrincipalFunction.cs b/MM.API/Functions/PrincipalFunction.cs index a3bb31a..3d97fd6 100644 --- a/MM.API/Functions/PrincipalFunction.cs +++ b/MM.API/Functions/PrincipalFunction.cs @@ -1,12 +1,10 @@ -using Microsoft.Azure.Cosmos; using Microsoft.Azure.Functions.Worker; using Microsoft.Azure.Functions.Worker.Http; -using MM.API.Repository.Core; using MM.Shared.Models.Auth; namespace MM.API.Functions { - public class PrincipalFunction(IRepository repo) + public class PrincipalFunction(CosmosRepository repo) { //[OpenApiOperation("PrincipalGet", "Azure (Cosmos DB)")] //[OpenApiResponseWithBody(HttpStatusCode.OK, "application/json", typeof(ClientePrincipal))] @@ -18,7 +16,7 @@ public class PrincipalFunction(IRepository repo) { var userId = req.GetUserId(); - return await repo.Get(DocumentType.Principal + ":" + userId, new PartitionKey(userId), cancellationToken); + return await repo.Get(DocumentType.Principal, userId, cancellationToken); } catch (Exception ex) { @@ -35,7 +33,7 @@ public class PrincipalFunction(IRepository repo) { var token = req.GetQueryParameters()["token"]; - var principal = await repo.Get(DocumentType.Principal + ":" + token, new PartitionKey(token), cancellationToken); + var principal = await repo.Get(DocumentType.Principal, token, cancellationToken); return principal?.Email; } catch (Exception ex) @@ -72,7 +70,7 @@ public async Task Paddle( { var userId = req.GetUserId(); - var Client = await repo.Get(DocumentType.Principal + ":" + userId, new PartitionKey(userId), cancellationToken) ?? throw new NotificationException("Client null"); + var Client = await repo.Get(DocumentType.Principal, userId, cancellationToken) ?? throw new NotificationException("Client null"); var body = await req.GetBody(cancellationToken); Client.ClientePaddle = body.ClientePaddle; @@ -94,31 +92,25 @@ public async Task Remove( { var userId = req.GetUserId(); - var myPrincipal = await repo.Get(DocumentType.Principal + ":" + userId, new PartitionKey(userId), cancellationToken); + var myPrincipal = await repo.Get(DocumentType.Principal, userId, cancellationToken); if (myPrincipal != null) await repo.Delete(myPrincipal, cancellationToken); - //var myProviders = await repo.Get(DocumentType.MyProvider + ":" + userId, new PartitionKey(userId), cancellationToken); + //var myProviders = await repo.Get(DocumentType.MyProvider, userId, cancellationToken); //if (myProviders != null) await repo.Delete(myProviders, cancellationToken); - var myLogins = await repo.Get(DocumentType.Login + ":" + userId, new PartitionKey(userId), cancellationToken); + var myLogins = await repo.Get(DocumentType.Login, userId, cancellationToken); if (myLogins != null) await repo.Delete(myLogins, cancellationToken); - //var mySuggestions = await repo.Get(DocumentType.MySuggestions + ":" + userId, new PartitionKey(userId), cancellationToken); + //var mySuggestions = await repo.Get(DocumentType.MySuggestions, userId, cancellationToken); //if (mySuggestions != null) await repo.Delete(mySuggestions, cancellationToken); - //var myVotes = await repo.Query(x => x.IdVotedUser == userId, null, DocumentType.TicketVote, cancellationToken); - //foreach (var vote in myVotes) - //{ - // if (vote != null) await repo.Delete(vote, cancellationToken); - //} - - //var myWatched = await repo.Get(DocumentType.WatchedList + ":" + userId, new PartitionKey(userId), cancellationToken); + //var myWatched = await repo.Get(DocumentType.WatchedList, userId, cancellationToken); //if (myWatched != null) await repo.Delete(myWatched, cancellationToken); - //var myWatching = await repo.Get(DocumentType.WatchingList + ":" + userId, new PartitionKey(userId), cancellationToken); + //var myWatching = await repo.Get(DocumentType.WatchingList, userId, cancellationToken); //if (myWatching != null) await repo.Delete(myWatching, cancellationToken); - //var myWish = await repo.Get(DocumentType.WishList + ":" + userId, new PartitionKey(userId), cancellationToken); + //var myWish = await repo.Get(DocumentType.WishList, userId, cancellationToken); //if (myWish != null) await repo.Delete(myWish, cancellationToken); } catch (Exception ex) diff --git a/MM.API/Functions/ProfileFunction.cs b/MM.API/Functions/ProfileFunction.cs index 596b269..1eacb7e 100644 --- a/MM.API/Functions/ProfileFunction.cs +++ b/MM.API/Functions/ProfileFunction.cs @@ -1,19 +1,13 @@ using Microsoft.Azure.Cosmos; using Microsoft.Azure.Functions.Worker; using Microsoft.Azure.Functions.Worker.Http; -using MM.API.Repository.Core; using MM.Shared.Models.Profile; namespace VerusDate.Api.Function { - public class ProfileFunction + public class ProfileFunction(CosmosRepository repo) { - private readonly IRepository _repo; - - public ProfileFunction(IRepository repo) - { - _repo = repo; - } + private readonly CosmosRepository _repo = repo; [Function("ProfileGet")] public async Task Get( @@ -23,7 +17,7 @@ public ProfileFunction(IRepository repo) { var userId = req.GetUserId(); - return await _repo.Get(DocumentType.Profile + ":" + userId, new PartitionKey(userId), cancellationToken); + return await _repo.Get(DocumentType.Profile, userId, cancellationToken); } catch (Exception ex) { @@ -109,7 +103,7 @@ public async Task UpdateLooking( PatchOperation.Add("/dtUpdate", DateTime.UtcNow) }; - return await _repo.PatchItem(DocumentType.Profile + ":" + userId, new PartitionKey(userId), operations, cancellationToken); + return await _repo.PatchItem(DocumentType.Profile, userId, operations, cancellationToken); } catch (Exception ex) { @@ -118,24 +112,34 @@ public async Task UpdateLooking( } } - //[Function("ProfileViewUpdatePatner")] - //public async Task UpdatePatner( - // [HttpTrigger(AuthorizationLevel.Function, Method.PUT, Route = "Profile/UpdatePatner")] HttpRequestData req, CancellationToken cancellationToken) - //{ - // try - // { - // var request = await req.BuildRequestCommand(source.Token, false); - // request.LoggedUserId = req.GetUserId(); + [Function("ProfileViewUpdatePatner")] + public async Task UpdatePatner( + [HttpTrigger(AuthorizationLevel.Function, Method.PUT, Route = "profile/update-partner")] HttpRequestData req, CancellationToken cancellationToken) + { + try + { + //var request = await req.BuildRequestCommand(source.Token, false); + //request.LoggedUserId = req.GetUserId(); - // var result = await _mediator.Send(request, source.Token); + //var result = await _mediator.Send(request, source.Token); - // return new OkObjectResult(result); - // } - // catch (Exception ex) - // { - // req.ProcessException(ex); - // throw new UnhandledException(ex.BuildException()); - // } - //} + //return new OkObjectResult(result); + + var id = req.GetQueryParameters()["id"]; + var email = req.GetQueryParameters()["email"]; + var userId = req.GetUserId(); + + var obj = await _repo.Get(DocumentType.Profile, userId, cancellationToken); + + obj?.UpdatePartner(id, email); + + return await _repo.Upsert(obj, cancellationToken); + } + catch (Exception ex) + { + req.ProcessException(ex); + throw new UnhandledException(ex.BuildException()); + } + } } } \ No newline at end of file diff --git a/MM.API/Functions/SendgridFunction.cs b/MM.API/Functions/SendgridFunction.cs index e227b0b..e45e4ae 100644 --- a/MM.API/Functions/SendgridFunction.cs +++ b/MM.API/Functions/SendgridFunction.cs @@ -33,7 +33,7 @@ public async Task EmailUpdate( { var Email = await req.GetPublicBody(cancellationToken); - await repo.Upsert(Email, cancellationToken); + await repo.UpsertItemAsync(Email, cancellationToken); } catch (Exception ex) { @@ -65,7 +65,7 @@ public async Task SendgridInbound( SenderIp = inboundMail.SenderIp }; - await repo.Upsert(model, cancellationToken); + await repo.CreateItemAsync(model, cancellationToken); } catch (Exception ex) { diff --git a/MM.API/Functions/SupportFunction.cs b/MM.API/Functions/SupportFunction.cs index 5aba409..ae7c1b4 100644 --- a/MM.API/Functions/SupportFunction.cs +++ b/MM.API/Functions/SupportFunction.cs @@ -1,12 +1,10 @@ -using Microsoft.Azure.Cosmos; using Microsoft.Azure.Functions.Worker; using Microsoft.Azure.Functions.Worker.Http; -using MM.API.Repository.Core; using MM.Shared.Models.Support; namespace MM.API.Functions { - public class SupportFunction(IRepository repo) + public class SupportFunction(CosmosRepository repo) { //[OpenApiOperation("UpdatesGet", "Azure (Cosmos DB)")] //[OpenApiResponseWithBody(HttpStatusCode.OK, "application/json", typeof(AnnouncementModel))] @@ -32,7 +30,7 @@ public async Task UpdatesAdd( try { var item = await req.GetPublicBody(cancellationToken); - var dbItem = await repo.Get(DocumentType.Update + ":" + item.Key, new PartitionKey(item.Key), cancellationToken); + var dbItem = await repo.Get(DocumentType.Update, item.Id, cancellationToken); if (dbItem != null) { @@ -80,7 +78,7 @@ public async Task> TicketGetList( { var userId = req.GetUserId(); - return await repo.Query(m => m.TicketStatus != TicketStatus.New || m.IdUserOwner == userId, null, DocumentType.Ticket, cancellationToken); + return await repo.Query(m => m.TicketStatus != TicketStatus.New || m.IdUserOwner == userId, DocumentType.Ticket, cancellationToken); } catch (Exception ex) { @@ -104,25 +102,6 @@ public async Task> TicketGetAll( } } - //[OpenApiOperation("TicketGetMyVotes", "Azure (Cosmos DB)")] - //[OpenApiResponseWithBody(HttpStatusCode.OK, "application/json", typeof(List))] - [Function("TicketGetMyVotes")] - public async Task> TicketGetMyVotes( - [HttpTrigger(AuthorizationLevel.Anonymous, Method.GET, Route = "Ticket/GetMyVotes")] HttpRequestData req, CancellationToken cancellationToken) - { - try - { - var userId = req.GetUserId(); - - return await repo.Query(x => x.IdVotedUser == userId, null, DocumentType.TicketVote, cancellationToken); - } - catch (Exception ex) - { - req.ProcessException(ex); - throw new UnhandledException(ex.BuildException()); - } - } - //[OpenApiOperation("TicketInsert", "Azure (Cosmos DB)")] //[OpenApiResponseWithBody(HttpStatusCode.OK, "application/json", typeof(TicketModel))] [Function("TicketInsert")] @@ -141,31 +120,5 @@ public async Task> TicketGetMyVotes( throw new UnhandledException(ex.BuildException()); } } - - //[OpenApiOperation("TicketVote", "Azure (Cosmos DB)")] - //[OpenApiResponseWithBody(HttpStatusCode.OK, "application/json", typeof(TicketVoteModel))] - [Function("TicketVote")] - public async Task TicketVote( - [HttpTrigger(AuthorizationLevel.Anonymous, Method.POST, Route = "Ticket/Vote")] HttpRequestData req, CancellationToken cancellationToken) - { - try - { - var item = await req.GetPublicBody(cancellationToken); - - if (item.VoteType == VoteType.PlusOne) - await repo.PatchItem(nameof(DocumentType.Ticket) + ":" + item.Key, new PartitionKey(item.Key), [PatchOperation.Increment("/totalVotes", 1)], cancellationToken); - else if (item.VoteType == VoteType.MinusOne) - await repo.PatchItem(nameof(DocumentType.Ticket) + ":" + item.Key, new PartitionKey(item.Key), [PatchOperation.Increment("/totalVotes", -1)], cancellationToken); - - item.IdVotedUser = req.GetUserId(); - - return await repo.Upsert(item, cancellationToken); - } - catch (Exception ex) - { - req.ProcessException(ex); - throw new UnhandledException(ex.BuildException()); - } - } } } \ No newline at end of file diff --git a/MM.API/MM.API.csproj b/MM.API/MM.API.csproj index 8471dbe..b4988e0 100644 --- a/MM.API/MM.API.csproj +++ b/MM.API/MM.API.csproj @@ -23,15 +23,15 @@ - + - - + + - - + + - + diff --git a/MM.API/Program.cs b/MM.API/Program.cs index 2937e0e..299aa11 100644 --- a/MM.API/Program.cs +++ b/MM.API/Program.cs @@ -27,11 +27,11 @@ .ConfigureLogging(ConfigureLogging) .Build(); -host.Run(); +await host.RunAsync(); static void ConfigureServices(HostBuilderContext context, IServiceCollection services) { - services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddApplicationInsightsTelemetryWorkerService(); diff --git a/MM.API/Repository/Core/CosmosRepositoryExtensions.cs b/MM.API/Repository/Core/CosmosRepositoryExtensions.cs new file mode 100644 index 0000000..993b0ce --- /dev/null +++ b/MM.API/Repository/Core/CosmosRepositoryExtensions.cs @@ -0,0 +1,34 @@ +using Microsoft.Azure.Cosmos; + +namespace MM.API.Repository.Core +{ + public static class CosmosRepositoryExtensions + { + public static ItemRequestOptions? GetItemRequestOptions() + { + return new ItemRequestOptions + { + //to this work, the changes need to be made by frontend + //EnableContentResponseOnWrite = false + }; + } + + public static PatchItemRequestOptions? GetPatchItemRequestOptions() + { + return new PatchItemRequestOptions + { + //to this work, the changes need to be made by frontend + //EnableContentResponseOnWrite = false + }; + } + + public static QueryRequestOptions? GetQueryRequestOptions() + { + return new QueryRequestOptions() + { + //https://learn.microsoft.com/en-us/training/modules/measure-index-azure-cosmos-db-sql-api/4-measure-query-cost + MaxItemCount = 10, // - max itens per page + }; + } + } +} \ No newline at end of file diff --git a/MM.API/Repository/Core/IRepository.cs b/MM.API/Repository/Core/IRepository.cs deleted file mode 100644 index e46da7f..0000000 --- a/MM.API/Repository/Core/IRepository.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Microsoft.Azure.Cosmos; -using System.Linq.Expressions; - -namespace MM.API.Repository.Core -{ - public interface IRepository - { - Task Get(string id, PartitionKey key, CancellationToken cancellationToken) where T : CosmosDocument; - - Task> ListAll(DocumentType Type, CancellationToken cancellationToken) where T : MainDocument; - - Task> Query(Expression> predicate, PartitionKey? key, DocumentType Type, CancellationToken cancellationToken) where T : MainDocument; - - Task Upsert(T item, CancellationToken cancellationToken) where T : CosmosDocument; - - Task PatchItem(string id, PartitionKey key, List operations, CancellationToken cancellationToken) where T : CosmosDocument; - - Task Delete(T item, CancellationToken cancellationToken) where T : CosmosDocument; - } -} \ No newline at end of file diff --git a/MM.API/Repository/CosmosCacheRepository.cs b/MM.API/Repository/CosmosCacheRepository.cs index f3b4455..b00f92f 100644 --- a/MM.API/Repository/CosmosCacheRepository.cs +++ b/MM.API/Repository/CosmosCacheRepository.cs @@ -1,6 +1,7 @@ using Microsoft.Azure.Cosmos; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; +using MM.API.Repository.Core; namespace MM.API.Repository { @@ -19,15 +20,15 @@ public CosmosCacheRepository(IConfiguration config, ILogger?> Get(string key, CancellationToken cancellationToken) where TData : class + public async Task?> Get(string id, CancellationToken cancellationToken) where TData : class { try { - var response = await Container.ReadItemAsync?>(key, new PartitionKey(key), null, cancellationToken); + var response = await Container.ReadItemAsync?>(id, new PartitionKey(id), CosmosRepositoryExtensions.GetItemRequestOptions(), cancellationToken); - if (response.RequestCharge > 1.7) + if (response.RequestCharge > 1.5) { - _logger.LogWarning("Get - key {0}, RequestCharge {1}", key, response.RequestCharge); + _logger.LogWarning("Get - Id {0}, RequestCharge {1}", id, response.RequestCharge); } return response.Resource; @@ -38,13 +39,13 @@ public CosmosCacheRepository(IConfiguration config, ILogger?> Add(CacheDocument cache, CancellationToken cancellationToken) where TData : class + public async Task?> CreateItemAsync(CacheDocument cache, CancellationToken cancellationToken) where TData : class { - var response = await Container.UpsertItemAsync(cache, new PartitionKey(cache.Key), null, cancellationToken); + var response = await Container.CreateItemAsync(cache, new PartitionKey(cache.Id), CosmosRepositoryExtensions.GetItemRequestOptions(), cancellationToken); if (response.RequestCharge > 12) { - _logger.LogWarning("Add - Key {0}, RequestCharge {1}", cache.Key, response.RequestCharge); + _logger.LogWarning("Add - Id {0}, RequestCharge {1}", cache.Id, response.RequestCharge); } return response.Resource; diff --git a/MM.API/Repository/CosmosEmailRepository.cs b/MM.API/Repository/CosmosEmailRepository.cs index 103a6e3..032130e 100644 --- a/MM.API/Repository/CosmosEmailRepository.cs +++ b/MM.API/Repository/CosmosEmailRepository.cs @@ -1,6 +1,7 @@ using Microsoft.Azure.Cosmos; using Microsoft.Azure.Cosmos.Linq; using Microsoft.Extensions.Configuration; +using MM.API.Repository.Core; using MM.Shared.Models.Support; using System.Linq.Expressions; @@ -18,11 +19,11 @@ public CosmosEmailRepository(IConfiguration config) Container = ApiStartup.CosmosClient.GetContainer(databaseId, containerId); } - public async Task Get(string key, CancellationToken cancellationToken) + public async Task Get(string id, CancellationToken cancellationToken) { try { - var response = await Container.ReadItemAsync(key, new PartitionKey(key), null, cancellationToken); + var response = await Container.ReadItemAsync(id, new PartitionKey(id), CosmosRepositoryExtensions.GetItemRequestOptions(), cancellationToken); return response.Resource; } @@ -61,9 +62,16 @@ public async Task> Query(Expression Upsert(EmailDocument email, CancellationToken cancellationToken) + public async Task UpsertItemAsync(EmailDocument email, CancellationToken cancellationToken) { - var response = await Container.UpsertItemAsync(email, new PartitionKey(email.Key), null, cancellationToken); + var response = await Container.UpsertItemAsync(email, new PartitionKey(email.Id), CosmosRepositoryExtensions.GetItemRequestOptions(), cancellationToken); + + return response.Resource; + } + + public async Task CreateItemAsync(EmailDocument email, CancellationToken cancellationToken) + { + var response = await Container.CreateItemAsync(email, new PartitionKey(email.Id), CosmosRepositoryExtensions.GetItemRequestOptions(), cancellationToken); return response.Resource; } diff --git a/MM.API/Repository/CosmosLogRepository.cs b/MM.API/Repository/CosmosLogRepository.cs index 5e8f327..da6cddf 100644 --- a/MM.API/Repository/CosmosLogRepository.cs +++ b/MM.API/Repository/CosmosLogRepository.cs @@ -1,5 +1,6 @@ using Microsoft.Azure.Cosmos; using Microsoft.Extensions.Configuration; +using MM.API.Repository.Core; namespace MM.API.Repository { @@ -8,11 +9,9 @@ public class LogModel public LogModel() { Id = Guid.NewGuid().ToString(); - Key = DateTime.UtcNow.ToShortDateString(); } public string? Id { get; set; } - public string? Key { get; set; } public string? Name { get; set; } public string? State { get; set; } public string? Message { get; set; } @@ -34,7 +33,7 @@ public CosmosLogRepository(IConfiguration config) public async Task Add(LogModel log) { - await Container.CreateItemAsync(log, new PartitionKey(log.Key), null); + await Container.CreateItemAsync(log, new PartitionKey(log.Id), CosmosRepositoryExtensions.GetItemRequestOptions()); } } } \ No newline at end of file diff --git a/MM.API/Repository/CosmosRepository.cs b/MM.API/Repository/CosmosRepository.cs index 0021cd4..dee170c 100644 --- a/MM.API/Repository/CosmosRepository.cs +++ b/MM.API/Repository/CosmosRepository.cs @@ -7,7 +7,7 @@ namespace MM.API.Repository { - public class CosmosRepository : IRepository + public class CosmosRepository { public Container Container { get; private set; } private readonly ILogger _logger; @@ -22,15 +22,15 @@ public CosmosRepository(IConfiguration config, ILogger logger) Container = ApiStartup.CosmosClient.GetContainer(databaseId, containerId); } - public async Task Get(string id, PartitionKey key, CancellationToken cancellationToken) where T : CosmosDocument + public async Task Get(DocumentType type, string? id, CancellationToken cancellationToken) where T : CosmosDocument { if (string.IsNullOrEmpty(id)) throw new ArgumentNullException(nameof(id)); try { - var response = await Container.ReadItemAsync(id, key, null, cancellationToken); + var response = await Container.ReadItemAsync($"{type}:{id}", new PartitionKey($"{type}:{id}"), CosmosRepositoryExtensions.GetItemRequestOptions(), cancellationToken); - if (response.RequestCharge > 1.8) + if (response.RequestCharge > 1.5) { _logger.LogWarning("Get - ID {0}, RequestCharge {1}", id, response.RequestCharge); } @@ -45,7 +45,9 @@ public CosmosRepository(IConfiguration config, ILogger logger) public async Task> ListAll(DocumentType Type, CancellationToken cancellationToken) where T : MainDocument { - var query = Container.GetItemLinqQueryable(requestOptions: CosmosRepositoryExtensions.GetDefaultOptions(null)).Where(item => item.Type == Type); + var query = Container + .GetItemLinqQueryable(requestOptions: CosmosRepositoryExtensions.GetQueryRequestOptions()) + .Where(item => item.Type == Type); using var iterator = query.ToFeedIterator(); var results = new List(); @@ -60,16 +62,17 @@ public async Task> ListAll(DocumentType Type, CancellationToken cance if (charges > 5) { - _logger.LogWarning("ListAll - Type {0}, RequestCharge {1}", Type.ToString(), charges); + _logger.LogWarning("ListAll - Type {Type}, RequestCharge {Charges}", Type.ToString(), charges); } return results; } - public async Task> Query(Expression> predicate, PartitionKey? key, DocumentType Type, CancellationToken cancellationToken) where T : MainDocument + public async Task> Query(Expression> predicate, DocumentType Type, CancellationToken cancellationToken) where T : MainDocument { - var query = Container.GetItemLinqQueryable(requestOptions: CosmosRepositoryExtensions.GetDefaultOptions(key)) - .Where(predicate.Compose(item => item.Type == Type, Expression.AndAlso)); + var query = Container + .GetItemLinqQueryable(requestOptions: CosmosRepositoryExtensions.GetQueryRequestOptions()) + .Where(predicate.Compose(item => item.Type == Type, Expression.AndAlso)); using var iterator = query.ToFeedIterator(); var results = new List(); @@ -84,7 +87,7 @@ public async Task> Query(Expression> predicate, Partiti if (charges > 5) { - _logger.LogWarning("Query - Type {0}, RequestCharge {1}", Type.ToString(), charges); + _logger.LogWarning("Query - Type {Type}, RequestCharge {Charges}", Type.ToString(), charges); } return results; @@ -92,25 +95,25 @@ public async Task> Query(Expression> predicate, Partiti public async Task Upsert(T item, CancellationToken cancellationToken) where T : CosmosDocument { - var response = await Container.UpsertItemAsync(item, new PartitionKey(item.Key), null, cancellationToken); + var response = await Container.UpsertItemAsync(item, new PartitionKey(item.Id), CosmosRepositoryExtensions.GetItemRequestOptions(), cancellationToken); - if (response.RequestCharge > 20) + if (response.RequestCharge > 12) { - _logger.LogWarning("Upsert - ID {0}, Key {1}, RequestCharge {2}", item.Id, item.Key, response.RequestCharge); + _logger.LogWarning("Upsert - ID {Id}, RequestCharge {Charges}", item.Id, response.RequestCharge); } return response.Resource; } - public async Task PatchItem(string id, PartitionKey key, List operations, CancellationToken cancellationToken) where T : CosmosDocument + public async Task PatchItem(DocumentType type, string? id, List operations, CancellationToken cancellationToken) where T : CosmosDocument { //https://learn.microsoft.com/en-us/azure/cosmos-db/partial-document-update-getting-started?tabs=dotnet - var response = await Container.PatchItemAsync(id, key, operations, null, cancellationToken); + var response = await Container.PatchItemAsync($"{type}:{id}", new PartitionKey($"{type}:{id}"), operations, CosmosRepositoryExtensions.GetPatchItemRequestOptions(), cancellationToken); - if (response.RequestCharge > 20) + if (response.RequestCharge > 12) { - _logger.LogWarning("PatchItem - ID {0}, Key {1}, RequestCharge {2}", id, key, response.RequestCharge); + _logger.LogWarning("PatchItem - ID {Id}, RequestCharge {Charges}", id, response.RequestCharge); } return response.Resource; @@ -118,11 +121,11 @@ public async Task PatchItem(string id, PartitionKey key, List Delete(T item, CancellationToken cancellationToken) where T : CosmosDocument { - var response = await Container.DeleteItemAsync(item.Id, new PartitionKey(item.Key), null, cancellationToken); + var response = await Container.DeleteItemAsync(item.Id, new PartitionKey(item.Id), CosmosRepositoryExtensions.GetItemRequestOptions(), cancellationToken); - if (response.RequestCharge > 8) + if (response.RequestCharge > 12) { - _logger.LogWarning("Delete - ID {0}, Key {1}, RequestCharge {2}", item.Id, item.Key, response.RequestCharge); + _logger.LogWarning("Delete - ID {Id}, RequestCharge {Charges}", item.Id, response.RequestCharge); } return response.StatusCode == System.Net.HttpStatusCode.OK; @@ -137,22 +140,4 @@ public async Task Delete(T item, CancellationToken cancellationToken) w //composite indexes //https://docs.microsoft.com/pt-br/learn/modules/customize-indexes-azure-cosmos-db-sql-api/3-evaluate-composite-indexes } - - public static class CosmosRepositoryExtensions - { - public static QueryRequestOptions? GetDefaultOptions(PartitionKey? key) - { - if (key == null) - return null; - else - return new QueryRequestOptions() - { - PartitionKey = key, - //https://learn.microsoft.com/en-us/training/modules/measure-index-azure-cosmos-db-sql-api/4-measure-query-cost - MaxItemCount = 10, //max itens per page - //https://learn.microsoft.com/en-us/training/modules/measure-index-azure-cosmos-db-sql-api/2-enable-indexing-metrics - PopulateIndexMetrics = false //enable only when analysing metrics - }; - } - } } \ No newline at end of file diff --git a/MM.Shared/Core/CosmosDocument.cs b/MM.Shared/Core/CosmosDocument.cs index 1edff17..83b23d7 100644 --- a/MM.Shared/Core/CosmosDocument.cs +++ b/MM.Shared/Core/CosmosDocument.cs @@ -11,10 +11,9 @@ protected CosmosDocument() FixedId = false; } - protected CosmosDocument(string id, string key) + protected CosmosDocument(string id) { Id = id; - Key = key; FixedId = true; } @@ -22,9 +21,6 @@ protected CosmosDocument(string id, string key) [JsonInclude] public string Id { get; set; } = string.Empty; - [JsonInclude] - public string Key { get; set; } = string.Empty; - [JsonInclude] public DateTimeOffset DtInsert { get; set; } = DateTimeOffset.UtcNow; @@ -33,12 +29,11 @@ protected CosmosDocument(string id, string key) public abstract bool HasValidData(); - protected void SetIds(string id, string key) + protected void SetIds(string id) { if (FixedId) throw new InvalidOperationException(); Id = id; - Key = key; } public virtual void Update() diff --git a/MM.Shared/Core/Helper/CustomAttribute.cs b/MM.Shared/Core/Helper/CustomAttribute.cs index b05dc6b..27b0c32 100644 --- a/MM.Shared/Core/Helper/CustomAttribute.cs +++ b/MM.Shared/Core/Helper/CustomAttribute.cs @@ -46,7 +46,7 @@ public static class CustomAttributeHelper return fieldInfo.GetCustomAttribute(translate); } - public static CustomAttribute? GetCustomAttribute(this Expression> expression, bool translate = true) + public static CustomAttribute? GetCustomAttribute(this Expression>? expression, bool translate = true) { if (expression == null) return null; diff --git a/MM.Shared/Core/Helper/EnumHelper.cs b/MM.Shared/Core/Helper/EnumHelper.cs index 5af7dff..ce08fa7 100644 --- a/MM.Shared/Core/Helper/EnumHelper.cs +++ b/MM.Shared/Core/Helper/EnumHelper.cs @@ -18,24 +18,19 @@ public static IEnumerable GetList(bool translate = true) wher { var attr = val.GetCustomAttribute(translate); - yield return new EnumObject(val, attr?.Name, attr?.Description, attr?.Group); + yield return new EnumObject(val, attr?.Name, attr?.Description, attr?.Group, attr?.Prompt, attr?.FieldInfo, attr?.Tips); } } } - public class EnumObject + public class EnumObject(Enum value, string? name, string? description, string? group, string? prompt, string? fieldInfo, string? tips) { - public EnumObject(Enum value, string? name, string? description, string? group) - { - Value = value; - Name = name; - Description = description; - Group = group; - } - - public Enum Value { get; set; } - public string? Name { get; set; } - public string? Description { get; set; } - public string? Group { get; set; } + public Enum Value { get; set; } = value; + public string? Name { get; set; } = name; + public string? Description { get; set; } = description; + public string? Group { get; set; } = group; + public string? Prompt { get; set; } = prompt; + public string? FieldInfo { get; set; } = fieldInfo; + public string? Tips { get; set; } = tips; } } \ No newline at end of file diff --git a/MM.Shared/Core/Helper/ImageHelper.cs b/MM.Shared/Core/Helper/ImageHelper.cs index ee11697..6aa7ac7 100644 --- a/MM.Shared/Core/Helper/ImageHelper.cs +++ b/MM.Shared/Core/Helper/ImageHelper.cs @@ -9,7 +9,7 @@ public enum PhotoType PhotoValidation } - public static string GetNoUserPhoto => "img/noimage.png"; + public static string GetNoUserPhoto => "images/noimage.png"; public static string GetPhotoContainer(PhotoType type) { diff --git a/MM.Shared/Core/Helper/SubscriptionHelper.cs b/MM.Shared/Core/Helper/SubscriptionHelper.cs index 23ebe79..ec43ff4 100644 --- a/MM.Shared/Core/Helper/SubscriptionHelper.cs +++ b/MM.Shared/Core/Helper/SubscriptionHelper.cs @@ -69,7 +69,7 @@ public abstract class Restrictions public class BasicRestrictions : Restrictions { - public override int FavoriteProviders => 1; + public override int FavoriteProviders => 2; public override int MySuggestions => 0; public override int Watched => 10; public override int Watching => 6; diff --git a/MM.Shared/Core/Models/CacheDocument.cs b/MM.Shared/Core/Models/CacheDocument.cs index 977db2d..5d51a7a 100644 --- a/MM.Shared/Core/Models/CacheDocument.cs +++ b/MM.Shared/Core/Models/CacheDocument.cs @@ -8,7 +8,7 @@ protected CacheDocument() { } - protected CacheDocument(string key, TData data, ttlCache ttl) : base(key, key) + protected CacheDocument(string id, TData data, ttlCache ttl) : base(id) { Data = data; Ttl = (int)ttl; diff --git a/MM.Shared/Core/Models/LogDocument.cs b/MM.Shared/Core/Models/LogDocument.cs index 5ab91c8..3e2d4ee 100644 --- a/MM.Shared/Core/Models/LogDocument.cs +++ b/MM.Shared/Core/Models/LogDocument.cs @@ -2,7 +2,7 @@ { public abstract class LogDocument : CosmosDocument { - protected LogDocument(string id, string key) : base(id, key) + protected LogDocument(string id) : base(id) { } } diff --git a/MM.Shared/Core/Models/MainDocument.cs b/MM.Shared/Core/Models/MainDocument.cs index b23f313..4ed32b8 100644 --- a/MM.Shared/Core/Models/MainDocument.cs +++ b/MM.Shared/Core/Models/MainDocument.cs @@ -19,7 +19,7 @@ protected MainDocument(DocumentType type) Type = type; } - protected MainDocument(string id, string key, DocumentType type) : base($"{type}:{id}", key) + protected MainDocument(string id, DocumentType type) : base($"{type}:{id}") { Type = type; } @@ -39,14 +39,14 @@ protected ProtectedMainDocument(DocumentType type) : base(type) this.type = type; } - protected ProtectedMainDocument(string id, string key, DocumentType type) : base($"{type}:{id}", key, type) + protected ProtectedMainDocument(string id, DocumentType type) : base($"{type}:{id}", type) { this.type = type; } - public virtual void Initialize(string id, string key) + public virtual void Initialize(string id) { - SetIds($"{type}:{id}", key); + SetIds($"{type}:{id}"); } } @@ -64,7 +64,7 @@ protected PrivateMainDocument(DocumentType type) : base(type) public virtual void Initialize(string userId) { - SetIds($"{type}:{userId}", userId); + SetIds($"{type}:{userId}"); } } } \ No newline at end of file diff --git a/MM.Shared/Enums/ChineseZodiac.cs b/MM.Shared/Enums/ChineseZodiac.cs deleted file mode 100644 index a4de47c..0000000 --- a/MM.Shared/Enums/ChineseZodiac.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace MM.Shared.Enums -{ - //https://www.chinahighlights.com/travelguide/chinese-zodiac/ - //https://www.travelchinaguide.com/intro/social_customs/zodiac/ - //https://en.wikipedia.org/wiki/Chinese_zodiac - public class ChineseZodiac - { - //https://en.wikipedia.org/wiki/Astrological_sign - //https://sciencing.com/types-zodiacs-there-other-chinese-8457677.html - //https://www.rustico.com/blogs/news/whats-your-sign-astrological-signs-from-around-the-world - //https://trusted-astrology.com/types-of-zodiac-signs/ - } -} \ No newline at end of file diff --git a/MM.Shared/Enums/Country.cs b/MM.Shared/Enums/Country.cs index 71b0ee5..750a1e5 100644 --- a/MM.Shared/Enums/Country.cs +++ b/MM.Shared/Enums/Country.cs @@ -1,321 +1,758 @@ namespace MM.Shared.Enums { /// - /// https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_population /// https://en.wikipedia.org/wiki/ISO_3166-1 /// public enum Country { - [Custom(Group = "Asia", Name = "China")] - CHN = 156, + [Custom(Group = "Asia", Name = "Afghanistan", Tips = "AFG")] + Afghanistan = 4, - [Custom(Group = "Asia", Name = "India")] - IND = 356, + [Custom(Group = "Europe", Name = "Åland Islands", Tips = "ALA")] + AlandIslands = 248, - [Custom(Group = "Americas", Name = "United States")] - USA = 840, + [Custom(Group = "Europe", Name = "Albania", Tips = "ALB")] + Albania = 8, - [Custom(Group = "Asia", Name = "Indonesia")] - IDN = 360, + [Custom(Group = "Africa", Name = "Algeria", Tips = "DZA")] + Algeria = 12, - [Custom(Group = "Asia", Name = "Pakistan")] - PAK = 586, + [Custom(Group = "Oceania", Name = "American Samoa", Tips = "ASM")] + AmericanSamoa = 16, - [Custom(Group = "Africa", Name = "Nigeria")] - NGA = 566, + [Custom(Group = "Europe", Name = "Andorra", Tips = "AND")] + Andorra = 20, - [Custom(Group = "Americas", Name = "Brazil")] - BRA = 076, + [Custom(Group = "Africa", Name = "Angola", Tips = "AGO")] + Angola = 24, - [Custom(Group = "Asia", Name = "Bangladesh")] - BGD = 050, + [Custom(Group = "Americas", Name = "Anguilla", Tips = "AIA")] + Anguilla = 660, - [Custom(Group = "Europe", Name = "Russia")] - RUS = 643, + [Custom(Group = "Americas", Name = "Antigua and Barbuda", Tips = "ATG")] + AntiguaAndBarbuda = 28, - [Custom(Group = "Americas", Name = "Mexico")] - MEX = 484, + [Custom(Group = "Americas", Name = "Argentina", Tips = "ARG")] + Argentina = 32, - [Custom(Group = "Americas", Name = "Japan")] - JPN = 392, + [Custom(Group = "Asia", Name = "Armenia", Tips = "ARM")] + Armenia = 51, - [Custom(Group = "Americas", Name = "Ethiopia")] - ETH = 231, + [Custom(Group = "Americas", Name = "Aruba", Tips = "ABW")] + Aruba = 533, - [Custom(Group = "Americas", Name = "Philippines")] - PHL = 608, + [Custom(Group = "Oceania", Name = "Australia", Tips = "AUS")] + Australia = 36, - [Custom(Group = "Americas", Name = "Egypt")] - EGY = 818, + [Custom(Group = "Europe", Name = "Austria", Tips = "AUT")] + Austria = 40, - [Custom(Group = "Americas", Name = "Vietnam")] - VNM = 704, + [Custom(Group = "Asia", Name = "Azerbaijan", Tips = "AZE")] + Azerbaijan = 31, - [Custom(Group = "Americas", Name = "DR Congo")] - COD = 180, + [Custom(Group = "Americas", Name = "Bahamas", Tips = "BHS")] + Bahamas = 44, - [Custom(Group = "Americas", Name = "Iran")] - IRN = 364, + [Custom(Group = "Asia", Name = "Bahrain", Tips = "BHR")] + Bahrain = 48, - [Custom(Group = "Americas", Name = "Turkey")] - TUR = 792, + [Custom(Group = "Asia", Name = "Bangladesh", Tips = "BGD")] + Bangladesh = 50, - [Custom(Group = "Americas", Name = "Germany")] - DEU = 276, + [Custom(Group = "Americas", Name = "Barbados", Tips = "BRB")] + Barbados = 52, - [Custom(Group = "Americas", Name = "France")] - FRA = 250, + [Custom(Group = "Europe", Name = "Belarus", Tips = "BLR")] + Belarus = 112, - [Custom(Group = "Americas", Name = "United Kingdom")] - GBR = 826, + [Custom(Group = "Europe", Name = "Belgium", Tips = "BEL")] + Belgium = 56, - [Custom(Group = "Americas", Name = "Thailand")] - THA = 764, + [Custom(Group = "Americas", Name = "Belize", Tips = "BLZ")] + Belize = 84, - [Custom(Group = "Americas", Name = "South Africa")] - ZAF = 710, + [Custom(Group = "Africa", Name = "Benin", Tips = "BEN")] + Benin = 204, - [Custom(Group = "Americas", Name = "Tanzania")] - TZA = 834, + [Custom(Group = "Americas", Name = "Bermuda", Tips = "BMU")] + Bermuda = 60, - [Custom(Group = "Americas", Name = "Italy")] - ITA = 380, + [Custom(Group = "Asia", Name = "Bhutan", Tips = "BTN")] + Bhutan = 64, - [Custom(Group = "Americas", Name = "Myanmar")] - MMR = 104, + [Custom(Group = "Americas", Name = "Bolivia", Tips = "BOL")] + Bolivia = 68, - [Custom(Group = "Americas", Name = "South Korea")] - KOR = 410, + [Custom(Group = "Americas", Name = "Caribbean Netherlands", Tips = "BES")] + CaribbeanNetherlands = 535, - [Custom(Group = "Americas", Name = "Colombia")] - COL = 170, + [Custom(Group = "Europe", Name = "Bosnia and Herzegovina", Tips = "BIH")] + BosniaAndHerzegovina = 70, - [Custom(Group = "Americas", Name = "Kenya")] - KEN = 404, + [Custom(Group = "Africa", Name = "Botswana", Tips = "BWA")] + Botswana = 72, - [Custom(Group = "Americas", Name = "Spain")] - ESP = 724, + [Custom(Group = "Americas", Name = "Bouvet Island", Tips = "BVT")] + BouvetIsland = 74, - [Custom(Group = "Americas", Name = "Argentina")] - ARG = 032, + [Custom(Group = "Americas", Name = "Brazil", Tips = "BRA")] + Brazil = 76, - [Custom(Group = "Africa", Name = "Algeria")] - DZA = 012, + [Custom(Group = "Africa", Name = "British Indian Ocean Territory", Tips = "IOT")] + BritishIndianOceanTerritory = 86, - [Custom(Group = "Africa", Name = "Sudan")] - SDN = 729, + [Custom(Group = "Americas", Name = "British Virgin Islands", Tips = "VGB")] + BritishVirginIslands = 92, - [Custom(Group = "Africa", Name = "Uganda")] - UGA = 800, + [Custom(Group = "Asia", Name = "Brunei", Tips = "BRN")] + Brunei = 96, - [Custom(Group = "Asia", Name = "Iraq")] - IRQ = 368, + [Custom(Group = "Europe", Name = "Bulgaria", Tips = "BGR")] + Bulgaria = 100, - [Custom(Group = "Europe", Name = "Ukraine")] - UKR = 804, + [Custom(Group = "Africa", Name = "Burkina Faso", Tips = "BFA")] + BurkinaFaso = 854, - [Custom(Group = "Americas", Name = "Canada")] - CAN = 124, + [Custom(Group = "Africa", Name = "Burundi", Tips = "BDI")] + Burundi = 108, - [Custom(Group = "Europe", Name = "Poland")] - POL = 616, + [Custom(Group = "Asia", Name = "Cambodia", Tips = "KHM")] + Cambodia = 116, - [Custom(Group = "Africa", Name = "Morocco")] - MAR = 504, + [Custom(Group = "Africa", Name = "Cameroon", Tips = "CMR")] + Cameroon = 120, - [Custom(Group = "Asia", Name = "Uzbekistan")] - UZB = 860, + [Custom(Group = "Americas", Name = "Canada", Tips = "CAN")] + Canada = 124, - [Custom(Group = "Asia", Name = "Saudi Arabia")] - SAU = 682, + [Custom(Group = "Africa", Name = "Cape Verde", Tips = "CPV")] + CapeVerde = 132, - [Custom(Group = "Americas", Name = "Peru")] - PER = 604, + [Custom(Group = "Americas", Name = "Cayman Islands", Tips = "CYM")] + CaymanIslands = 136, - [Custom(Group = "Africa", Name = "Angola")] - AGO = 024, + [Custom(Group = "Africa", Name = "Central African Republic", Tips = "CAF")] + CentralAfricanRepublic = 140, - [Custom(Group = "Asia", Name = "Afghanistan")] - AFG = 004, + [Custom(Group = "Africa", Name = "Chad", Tips = "TCD")] + Chad = 148, - [Custom(Group = "Asia", Name = "Malaysia")] - MYS = 458, + [Custom(Group = "Americas", Name = "Chile", Tips = "CHL")] + Chile = 152, - [Custom(Group = "Africa", Name = "Mozambique")] - MOZ = 508, + [Custom(Group = "Asia", Name = "China", Tips = "CHN")] + China = 156, - [Custom(Group = "Africa", Name = "Ghana")] - GHA = 288, + [Custom(Group = "Asia", Name = "Hong Kong", Tips = "HKG")] + HongKong = 344, - [Custom(Group = "Asia", Name = "Yemen")] - YEM = 887, + [Custom(Group = "Asia", Name = "Macao", Tips = "MAC")] + Macao = 446, - [Custom(Group = "Asia", Name = "Nepal")] - NPL = 524, + [Custom(Group = "Oceania", Name = "Christmas Island", Tips = "CXR")] + ChristmasIsland = 162, - [Custom(Group = "Americas", Name = "Venezuela")] - VEN = 862, + [Custom(Group = "Oceania", Name = "Cocos (Keeling) Islands", Tips = "CCK")] + CocosKeelingIslands = 166, - [Custom(Group = "Africa", Name = "Ivory Coast")] - CIV = 384, + [Custom(Group = "Americas", Name = "Colombia", Tips = "COL")] + Colombia = 170, - [Custom(Group = "Africa", Name = "Madagascar")] - MDG = 450, + [Custom(Group = "Africa", Name = "Comoros", Tips = "COM")] + Comoros = 174, - [Custom(Group = "Oceania", Name = "Australia")] - AUS = 036, + [Custom(Group = "Africa", Name = "Republic of the Congo", Tips = "COG")] + RepublicOfTheCongo = 178, - [Custom(Group = "Asia", Name = "North Korea")] - PRK = 408, + [Custom(Group = "Oceania", Name = "Cook Islands", Tips = "COK")] + CookIslands = 184, - [Custom(Group = "Africa", Name = "Cameroon")] - CMR = 120, + [Custom(Group = "Americas", Name = "Costa Rica", Tips = "CRI")] + CostaRica = 188, - [Custom(Group = "Africa", Name = "Niger")] - NER = 562, + [Custom(Group = "Africa", Name = "Ivory Coast", Tips = "CIV")] + IvoryCoast = 384, - [Custom(Group = "Asia", Name = "Taiwan")] - TWN = 158, + [Custom(Group = "Europe", Name = "Croatia", Tips = "HRV")] + Croatia = 191, - [Custom(Group = "Asia", Name = "Sri Lanka")] - LKA = 144, + [Custom(Group = "Americas", Name = "Cuba", Tips = "CUB")] + Cuba = 192, - [Custom(Group = "Africa", Name = "Burkina Faso")] - BFA = 854, + [Custom(Group = "Americas", Name = "Curacao", Tips = "CUW")] + Curacao = 531, - [Custom(Group = "Africa", Name = "Malawi")] - MWI = 454, + [Custom(Group = "Asia", Name = "Cyprus", Tips = "CYP")] + Cyprus = 196, - [Custom(Group = "Africa", Name = "Mali")] - MLI = 466, + [Custom(Group = "Europe", Name = "Czechia", Tips = "CZE")] + Czechia = 203, - [Custom(Group = "Americas", Name = "Chile")] - CHL = 152, + [Custom(Group = "Africa", Name = "Democratic Republic of the Congo", Tips = "COD")] + DemocraticRepublicOfTheCongo = 180, - [Custom(Group = "Asia", Name = "Kazakhstan")] - KAZ = 398, + [Custom(Group = "Europe", Name = "Denmark", Tips = "DNK")] + Denmark = 208, - [Custom(Group = "Europe", Name = "Romania")] - ROU = 642, + [Custom(Group = "Africa", Name = "Djibouti", Tips = "DJI")] + Djibouti = 262, - [Custom(Group = "Africa", Name = "Zambia")] - ZMB = 894, + [Custom(Group = "Americas", Name = "Dominica", Tips = "DMA")] + Dominica = 212, - [Custom(Group = "Asia", Name = "Syria")] - SYR = 760, + [Custom(Group = "Americas", Name = "Dominican Republic", Tips = "DOM")] + DominicanRepublic = 214, - [Custom(Group = "Americas", Name = "Ecuador")] - ECU = 218, + [Custom(Group = "Americas", Name = "Ecuador", Tips = "ECU")] + Ecuador = 218, - [Custom(Group = "Europe", Name = "Netherlands")] - NLD = 528, + [Custom(Group = "Africa", Name = "Egypt", Tips = "EGY")] + Egypt = 818, - [Custom(Group = "Africa", Name = "Senegal")] - SEN = 686, + [Custom(Group = "Americas", Name = "El Salvador", Tips = "SLV")] + ElSalvador = 222, - [Custom(Group = "Americas", Name = "Guatemala")] - GTM = 320, + [Custom(Group = "Africa", Name = "Equatorial Guinea", Tips = "GNQ")] + EquatorialGuinea = 226, - [Custom(Group = "Africa", Name = "Chad")] - TCD = 148, + [Custom(Group = "Africa", Name = "Eritrea", Tips = "ERI")] + Eritrea = 232, - [Custom(Group = "Africa", Name = "Somalia")] - SOM = 706, + [Custom(Group = "Europe", Name = "Estonia", Tips = "EST")] + Estonia = 233, - [Custom(Group = "Africa", Name = "Zimbabwe")] - ZWE = 716, + [Custom(Group = "Africa", Name = "Eswatini", Tips = "SWZ")] + Eswatini = 748, - [Custom(Group = "Asia", Name = "Cambodia")] - KHM = 116, + [Custom(Group = "Africa", Name = "Ethiopia", Tips = "ETH")] + Ethiopia = 231, - [Custom(Group = "Africa", Name = "South Sudan")] - SSD = 728, + [Custom(Group = "Americas", Name = "Falkland Islands", Tips = "FLK")] + FalklandIslands = 238, - [Custom(Group = "Africa", Name = "Rwanda")] - RWA = 646, + [Custom(Group = "Europe", Name = "Faroe Islands", Tips = "FRO")] + FaroeIslands = 234, - [Custom(Group = "Africa", Name = "Guinea")] - GIN = 324, + [Custom(Group = "Oceania", Name = "Fiji", Tips = "FJI")] + Fiji = 242, - [Custom(Group = "Africa", Name = "Burundi")] - BDI = 108, + [Custom(Group = "Europe", Name = "Finland", Tips = "FIN")] + Finland = 246, - [Custom(Group = "Africa", Name = "Benin")] - BEN = 204, + [Custom(Group = "Europe", Name = "France", Tips = "FRA")] + France = 250, - [Custom(Group = "Americas", Name = "Bolivia")] - BOL = 068, + [Custom(Group = "Americas", Name = "French Guiana", Tips = "GUF")] + FrenchGuiana = 254, - [Custom(Group = "Africa", Name = "Tunisia")] - TUN = 788, + [Custom(Group = "Oceania", Name = "French Polynesia", Tips = "PYF")] + FrenchPolynesia = 258, - [Custom(Group = "Americas", Name = "Haiti")] - HTI = 332, + [Custom(Group = "Africa", Name = "French Southern and Antarctic Lands", Tips = "ATF")] + FrenchSouthernAndAntarcticLands = 260, - [Custom(Group = "Europe", Name = "Belgium")] - BEL = 056, + [Custom(Group = "Africa", Name = "Gabon", Tips = "GAB")] + Gabon = 266, - [Custom(Group = "Asia", Name = "Jordan")] - JOR = 400, + [Custom(Group = "Africa", Name = "Gambia", Tips = "GMB")] + Gambia = 270, - [Custom(Group = "Americas", Name = "Cuba")] - CUB = 192, + [Custom(Group = "Asia", Name = "Georgia", Tips = "GEO")] + Georgia = 268, - [Custom(Group = "Europe", Name = "Greece")] - GRC = 300, + [Custom(Group = "Europe", Name = "Germany", Tips = "DEU")] + Germany = 276, - [Custom(Group = "Americas", Name = "Dominican Republic")] - DOM = 214, + [Custom(Group = "Africa", Name = "Ghana", Tips = "GHA")] + Ghana = 288, - [Custom(Group = "Europe", Name = "Czech Republic")] - CZE = 203, + [Custom(Group = "Europe", Name = "Gibraltar", Tips = "GIB")] + Gibraltar = 292, - [Custom(Group = "Europe", Name = "Sweden")] - SWE = 752, + [Custom(Group = "Europe", Name = "Greece", Tips = "GRC")] + Greece = 300, - [Custom(Group = "Europe", Name = "Portugal")] - PRT = 620, + [Custom(Group = "Americas", Name = "Greenland", Tips = "GRL")] + Greenland = 304, - [Custom(Group = "Asia", Name = "Azerbaijan")] - AZE = 031, + [Custom(Group = "Americas", Name = "Grenada", Tips = "GRD")] + Grenada = 308, - [Custom(Group = "Europe", Name = "Hungary")] - HUN = 348, + [Custom(Group = "Americas", Name = "Guadeloupe", Tips = "GLP")] + Guadeloupe = 312, - [Custom(Group = "Americas", Name = "Honduras")] - HND = 340, + [Custom(Group = "Oceania", Name = "Guam", Tips = "GUM")] + Guam = 316, - [Custom(Group = "Asia", Name = "Israel")] - ISR = 376, + [Custom(Group = "Americas", Name = "Guatemala", Tips = "GTM")] + Guatemala = 320, - [Custom(Group = "Asia", Name = "Tajikistan")] - TJK = 762, + [Custom(Group = "Europe", Name = "Guernsey", Tips = "GGY")] + Guernsey = 831, - [Custom(Group = "Europe", Name = "Belarus")] - BLR = 112, + [Custom(Group = "Africa", Name = "Guinea", Tips = "GIN")] + Guinea = 324, - [Custom(Group = "Asia", Name = "United Arab Emirates")] - ARE = 784, + [Custom(Group = "Africa", Name = "Guinea-Bissau", Tips = "GNB")] + GuineaBissau = 624, - [Custom(Group = "Oceania", Name = "Papua New Guinea")] - PNG = 598, + [Custom(Group = "Americas", Name = "Guyana", Tips = "GUY")] + Guyana = 328, - [Custom(Group = "Europe", Name = "Austria")] - AUT = 040, + [Custom(Group = "Americas", Name = "Haiti", Tips = "HTI")] + Haiti = 332, - [Custom(Group = "Europe", Name = "Switzerland")] - CHE = 756, + [Custom(Group = "Oceania", Name = "Heard Island and McDonald Islands", Tips = "HMD")] + HeardIslandAndMcDonaldIslands = 334, - [Custom(Group = "Africa", Name = "Sierra Leone")] - SLE = 694, + [Custom(Group = "Europe", Name = "Vatican City", Tips = "VAT")] + VaticanCity = 336, - [Custom(Group = "Africa", Name = "Togo")] - TGO = 768, + [Custom(Group = "Americas", Name = "Honduras", Tips = "HND")] + Honduras = 340, - [Custom(Group = "Asia", Name = "Hong Kong")] - HKG = 344, + [Custom(Group = "Europe", Name = "Hungary", Tips = "HUN")] + Hungary = 348, - [Custom(Group = "Americas", Name = "Paraguay")] - PRY = 600 + [Custom(Group = "Europe", Name = "Iceland", Tips = "ISL")] + Iceland = 352, + + [Custom(Group = "Asia", Name = "India", Tips = "IND")] + India = 356, + + [Custom(Group = "Asia", Name = "Indonesia", Tips = "IDN")] + Indonesia = 360, + + [Custom(Group = "Asia", Name = "Iran", Tips = "IRN")] + Iran = 364, + + [Custom(Group = "Asia", Name = "Iraq", Tips = "IRQ")] + Iraq = 368, + + [Custom(Group = "Europe", Name = "Ireland", Tips = "IRL")] + Ireland = 372, + + [Custom(Group = "Europe", Name = "Isle of Man", Tips = "IMN")] + IsleOfMan = 833, + + [Custom(Group = "Asia", Name = "Israel", Tips = "ISR")] + Israel = 376, + + [Custom(Group = "Europe", Name = "Italy", Tips = "ITA")] + Italy = 380, + + [Custom(Group = "Americas", Name = "Jamaica", Tips = "JAM")] + Jamaica = 388, + + [Custom(Group = "Asia", Name = "Japan", Tips = "JPN")] + Japan = 392, + + [Custom(Group = "Europe", Name = "Jersey", Tips = "JEY")] + Jersey = 832, + + [Custom(Group = "Asia", Name = "Jordan", Tips = "JOR")] + Jordan = 400, + + [Custom(Group = "Asia", Name = "Kazakhstan", Tips = "KAZ")] + Kazakhstan = 398, + + [Custom(Group = "Africa", Name = "Kenya", Tips = "KEN")] + Kenya = 404, + + [Custom(Group = "Oceania", Name = "Kiribati", Tips = "KIR")] + Kiribati = 296, + + [Custom(Group = "Europe", Name = "Kosovo", Tips = "XKX")] + Kosovo = -1, + + [Custom(Group = "Asia", Name = "Kuwait", Tips = "KWT")] + Kuwait = 414, + + [Custom(Group = "Asia", Name = "Kyrgyzstan", Tips = "KGZ")] + Kyrgyzstan = 417, + + [Custom(Group = "Asia", Name = "Laos", Tips = "LAO")] + Laos = 418, + + [Custom(Group = "Europe", Name = "Latvia", Tips = "LVA")] + Latvia = 428, + + [Custom(Group = "Asia", Name = "Lebanon", Tips = "LBN")] + Lebanon = 422, + + [Custom(Group = "Africa", Name = "Lesotho", Tips = "LSO")] + Lesotho = 426, + + [Custom(Group = "Africa", Name = "Liberia", Tips = "LBR")] + Liberia = 430, + + [Custom(Group = "Africa", Name = "Libya", Tips = "LBY")] + Libya = 434, + + [Custom(Group = "Europe", Name = "Liechtenstein", Tips = "LIE")] + Liechtenstein = 438, + + [Custom(Group = "Europe", Name = "Lithuania", Tips = "LTU")] + Lithuania = 440, + + [Custom(Group = "Europe", Name = "Luxembourg", Tips = "LUX")] + Luxembourg = 442, + + [Custom(Group = "Africa", Name = "Madagascar", Tips = "MDG")] + Madagascar = 450, + + [Custom(Group = "Africa", Name = "Malawi", Tips = "MWI")] + Malawi = 454, + + [Custom(Group = "Asia", Name = "Malaysia", Tips = "MYS")] + Malaysia = 458, + + [Custom(Group = "Asia", Name = "Maldives", Tips = "MDV")] + Maldives = 462, + + [Custom(Group = "Africa", Name = "Mali", Tips = "MLI")] + Mali = 466, + + [Custom(Group = "Europe", Name = "Malta", Tips = "MLT")] + Malta = 470, + + [Custom(Group = "Oceania", Name = "Marshall Islands", Tips = "MHL")] + MarshallIslands = 584, + + [Custom(Group = "Americas", Name = "Martinique", Tips = "MTQ")] + Martinique = 474, + + [Custom(Group = "Africa", Name = "Mauritania", Tips = "MRT")] + Mauritania = 478, + + [Custom(Group = "Africa", Name = "Mauritius", Tips = "MUS")] + Mauritius = 480, + + [Custom(Group = "Africa", Name = "Mayotte", Tips = "MYT")] + Mayotte = 175, + + [Custom(Group = "Americas", Name = "Mexico", Tips = "MEX")] + Mexico = 484, + + [Custom(Group = "Oceania", Name = "Federated States of Micronesia", Tips = "FSM")] + FederatedStatesOfMicronesia = 583, + + [Custom(Group = "Europe", Name = "Principality of Monaco", Tips = "MCO")] + PrincipalityOfMonaco = 492, + + [Custom(Group = "Asia", Name = "Mongolia", Tips = "MNG")] + Mongolia = 496, + + [Custom(Group = "Europe", Name = "Montenegro", Tips = "MNE")] + Montenegro = 499, + + [Custom(Group = "Americas", Name = "Montserrat", Tips = "MSR")] + Montserrat = 500, + + [Custom(Group = "Africa", Name = "Morocco", Tips = "MAR")] + Morocco = 504, + + [Custom(Group = "Africa", Name = "Mozambique", Tips = "MOZ")] + Mozambique = 508, + + [Custom(Group = "Asia", Name = "Myanmar", Tips = "MMR")] + Myanmar = 104, + + [Custom(Group = "Africa", Name = "Namibia", Tips = "NAM")] + Namibia = 516, + + [Custom(Group = "Oceania", Name = "Nauru", Tips = "NRU")] + Nauru = 520, + + [Custom(Group = "Asia", Name = "Nepal", Tips = "NPL")] + Nepal = 524, + + [Custom(Group = "Europe", Name = "Netherlands", Tips = "NLD")] + Netherlands = 528, + + [Custom(Group = "Oceania", Name = "New Caledonia", Tips = "NCL")] + NewCaledonia = 540, + + [Custom(Group = "Oceania", Name = "New Zealand", Tips = "NZL")] + NewZealand = 554, + + [Custom(Group = "Americas", Name = "Nicaragua", Tips = "NIC")] + Nicaragua = 558, + + [Custom(Group = "Africa", Name = "Niger", Tips = "NER")] + Niger = 562, + + [Custom(Group = "Africa", Name = "Nigeria", Tips = "NGA")] + Nigeria = 566, + + [Custom(Group = "Oceania", Name = "Niue", Tips = "NIU")] + Niue = 570, + + [Custom(Group = "Oceania", Name = "Norfolk Island", Tips = "NFK")] + NorfolkIsland = 574, + + [Custom(Group = "Asia", Name = "North Korea", Tips = "PRK")] + NorthKorea = 408, + + [Custom(Group = "Europe", Name = "North Macedonia", Tips = "MKD")] + NorthMacedonia = 807, + + [Custom(Group = "Oceania", Name = "Northern Mariana Islands", Tips = "MNP")] + NorthernMarianaIslands = 580, + + [Custom(Group = "Europe", Name = "Norway", Tips = "NOR")] + Norway = 578, + + [Custom(Group = "Asia", Name = "Oman", Tips = "OMN")] + Oman = 512, + + [Custom(Group = "Asia", Name = "Pakistan", Tips = "PAK")] + Pakistan = 586, + + [Custom(Group = "Oceania", Name = "Palau", Tips = "PLW")] + Palau = 585, + + [Custom(Group = "Americas", Name = "Panama", Tips = "PAN")] + Panama = 591, + + [Custom(Group = "Oceania", Name = "Papua New Guinea", Tips = "PNG")] + PapuaNewGuinea = 598, + + [Custom(Group = "Americas", Name = "Paraguay", Tips = "PRY")] + Paraguay = 600, + + [Custom(Group = "Americas", Name = "Peru", Tips = "PER")] + Peru = 604, + + [Custom(Group = "Asia", Name = "Philippines", Tips = "PHL")] + Philippines = 608, + + [Custom(Group = "Oceania", Name = "Pitcairn Islands", Tips = "PCN")] + PitcairnIslands = 612, + + [Custom(Group = "Europe", Name = "Poland", Tips = "POL")] + Poland = 616, + + [Custom(Group = "Europe", Name = "Portugal", Tips = "PRT")] + Portugal = 620, + + [Custom(Group = "Americas", Name = "Puerto Rico", Tips = "PRI")] + PuertoRico = 630, + + [Custom(Group = "Asia", Name = "Qatar", Tips = "QAT")] + Qatar = 634, + + [Custom(Group = "Asia", Name = "South Korea", Tips = "KOR")] + SouthKorea = 410, + + [Custom(Group = "Europe", Name = "Moldova", Tips = "MDA")] + Moldova = 498, + + [Custom(Group = "Africa", Name = "Reunion", Tips = "REU")] + Reunion = 638, + + [Custom(Group = "Europe", Name = "Romania", Tips = "ROU")] + Romania = 642, + + [Custom(Group = "Europe", Name = "Russia", Tips = "RUS")] + Russia = 643, + + [Custom(Group = "Africa", Name = "Rwanda", Tips = "RWA")] + Rwanda = 646, + + [Custom(Group = "Americas", Name = "Saint Barthelemy", Tips = "BLM")] + SaintBarthelemy = 652, + + [Custom(Group = "Africa", Name = "Saint Helena, Ascension and Tristan da Cunha", Tips = "SHN")] + SaintHelenaAscensionAndTristanDaCunha = 654, + + [Custom(Group = "Americas", Name = "Saint Kitts and Nevis", Tips = "KNA")] + SaintKittsAndNevis = 659, + + [Custom(Group = "Americas", Name = "Saint Lucia", Tips = "LCA")] + SaintLucia = 662, + + [Custom(Group = "Americas", Name = "Saint Martin", Tips = "MAF")] + SaintMartin = 663, + + [Custom(Group = "Americas", Name = "Saint Pierre and Miquelon", Tips = "SPM")] + SaintPierreAndMiquelon = 666, + + [Custom(Group = "Americas", Name = "Saint Vincent and the Grenadines", Tips = "VCT")] + SaintVincentAndTheGrenadines = 670, + + [Custom(Group = "Oceania", Name = "Samoa", Tips = "WSM")] + Samoa = 882, + + [Custom(Group = "Europe", Name = "San Marino", Tips = "SMR")] + SanMarino = 674, + + [Custom(Group = "Africa", Name = "Sao Tome and Principe", Tips = "STP")] + SaoTomeAndPrincipe = 678, + + [Custom(Group = "Europe", Name = "Sark", Tips = "CRQ")] + Sark = 680, + + [Custom(Group = "Asia", Name = "Saudi Arabia", Tips = "SAU")] + SaudiArabia = 682, + + [Custom(Group = "Africa", Name = "Senegal", Tips = "SEN")] + Senegal = 686, + + [Custom(Group = "Europe", Name = "Serbia", Tips = "SRB")] + Serbia = 688, + + [Custom(Group = "Africa", Name = "Seychelles", Tips = "SYC")] + Seychelles = 690, + + [Custom(Group = "Africa", Name = "Sierra Leone", Tips = "SLE")] + SierraLeone = 694, + + [Custom(Group = "Asia", Name = "Singapore", Tips = "SGP")] + Singapore = 702, + + [Custom(Group = "Americas", Name = "Sint Maarten", Tips = "SXM")] + SintMaarten = 534, + + [Custom(Group = "Europe", Name = "Slovakia", Tips = "SVK")] + Slovakia = 703, + + [Custom(Group = "Europe", Name = "Slovenia", Tips = "SVN")] + Slovenia = 705, + + [Custom(Group = "Oceania", Name = "Solomon Islands", Tips = "SLB")] + SolomonIslands = 90, + + [Custom(Group = "Africa", Name = "Somalia", Tips = "SOM")] + Somalia = 706, + + [Custom(Group = "Africa", Name = "South Africa", Tips = "ZAF")] + SouthAfrica = 710, + + [Custom(Group = "Americas", Name = "South Georgia and South Sandwich Islands", Tips = "SGS")] + SouthGeorgiaAndSouthSandwichIslands = 239, + + [Custom(Group = "Africa", Name = "South Sudan", Tips = "SSD")] + SouthSudan = 728, + + [Custom(Group = "Europe", Name = "Spain", Tips = "ESP")] + Spain = 724, + + [Custom(Group = "Asia", Name = "Sri Lanka", Tips = "LKA")] + SriLanka = 144, + + [Custom(Group = "Asia", Name = "Palestine", Tips = "PSE")] + Palestine = 275, + + [Custom(Group = "Africa", Name = "Sudan", Tips = "SDN")] + Sudan = 729, + + [Custom(Group = "Americas", Name = "Suriname", Tips = "SUR")] + Suriname = 740, + + [Custom(Group = "Europe", Name = "Svalbard", Tips = "SJM")] + Svalbard = 744, + + [Custom(Group = "Europe", Name = "Sweden", Tips = "SWE")] + Sweden = 752, + + [Custom(Group = "Europe", Name = "Switzerland", Tips = "CHE")] + Switzerland = 756, + + [Custom(Group = "Asia", Name = "Syria", Tips = "SYR")] + Syria = 760, + + [Custom(Group = "Asia", Name = "Taiwan", Tips = "TWN")] + Taiwan = -2, + + [Custom(Group = "Asia", Name = "Tajikistan", Tips = "TJK")] + Tajikistan = 762, + + [Custom(Group = "Asia", Name = "Thailand", Tips = "THA")] + Thailand = 764, + + [Custom(Group = "Asia", Name = "East Timor", Tips = "TLS")] + EastTimor = 626, + + [Custom(Group = "Africa", Name = "Togo", Tips = "TGO")] + Togo = 768, + + [Custom(Group = "Oceania", Name = "Tokelau", Tips = "TKL")] + Tokelau = 772, + + [Custom(Group = "Oceania", Name = "Tonga", Tips = "TON")] + Tonga = 776, + + [Custom(Group = "Americas", Name = "Trinidad and Tobago", Tips = "TTO")] + TrinidadAndTobago = 780, + + [Custom(Group = "Africa", Name = "Tunisia", Tips = "TUN")] + Tunisia = 788, + + [Custom(Group = "Asia", Name = "Turkey", Tips = "TUR")] + Turkey = 792, + + [Custom(Group = "Asia", Name = "Turkmenistan", Tips = "TKM")] + Turkmenistan = 795, + + [Custom(Group = "Americas", Name = "Turks and Caicos Islands", Tips = "TCA")] + TurksAndCaicosIslands = 796, + + [Custom(Group = "Oceania", Name = "Tuvalu", Tips = "TUV")] + Tuvalu = 798, + + [Custom(Group = "Africa", Name = "Uganda", Tips = "UGA")] + Uganda = 800, + + [Custom(Group = "Europe", Name = "Ukraine", Tips = "UKR")] + Ukraine = 804, + + [Custom(Group = "Asia", Name = "United Arab Emirates", Tips = "ARE")] + UnitedArabEmirates = 784, + + [Custom(Group = "Europe", Name = "United Kingdom", Tips = "GBR")] + UnitedKingdom = 826, + + [Custom(Group = "Africa", Name = "Tanzania", Tips = "TZA")] + Tanzania = 834, + + [Custom(Group = "Oceania", Name = "United States Minor Outlying Islands", Tips = "UMI")] + UnitedStatesMinorOutlyingIslands = 581, + + [Custom(Group = "Americas", Name = "United States of America", Tips = "USA")] + UnitedStatesOfAmerica = 840, + + [Custom(Group = "Americas", Name = "Virgin Islands", Tips = "VIR")] + VirginIslands = 850, + + [Custom(Group = "Americas", Name = "Uruguay", Tips = "URY")] + Uruguay = 858, + + [Custom(Group = "Asia", Name = "Uzbekistan", Tips = "UZB")] + Uzbekistan = 860, + + [Custom(Group = "Oceania", Name = "Vanuatu", Tips = "VUT")] + Vanuatu = 548, + + [Custom(Group = "Americas", Name = "Venezuela", Tips = "VEN")] + Venezuela = 862, + + [Custom(Group = "Asia", Name = "Vietnam", Tips = "VNM")] + Vietnam = 704, + + [Custom(Group = "Oceania", Name = "Wallis and Futuna", Tips = "WLF")] + WallisAndFutuna = 876, + + [Custom(Group = "Africa", Name = "Western Sahara", Tips = "ESH")] + WesternSahara = 732, + + [Custom(Group = "Asia", Name = "Yemen", Tips = "YEM")] + Yemen = 887, + + [Custom(Group = "Africa", Name = "Zambia", Tips = "ZMB")] + Zambia = 894, + + [Custom(Group = "Africa", Name = "Zimbabwe", Tips = "ZWE")] + Zimbabwe = 716, } } \ No newline at end of file diff --git a/MM.Shared/Enums/Language.cs b/MM.Shared/Enums/Language.cs index 8f0280d..0abaeef 100644 --- a/MM.Shared/Enums/Language.cs +++ b/MM.Shared/Enums/Language.cs @@ -1,357 +1,560 @@ namespace MM.Shared.Enums { /// - /// https://en.wikipedia.org/wiki/List_of_languages_by_the_number_of_countries_in_which_they_are_recognized_as_an_official_language + /// https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes + /// https://en.wikipedia.org/wiki/List_of_official_languages + /// https://en.wikipedia.org/wiki/List_of_official_languages_by_country_and_territory /// /// public enum Language { - [Custom(Name = "English", Group = "Website", ResourceType = typeof(Resources.Language))] - en = 1, + [Custom(Name = "Abkhazian", Tips = "ab")] + Abkhazian, - [Custom(Name = "French", ResourceType = typeof(Resources.Language))] - fr = 2, + [Custom(Name = "Afar", Tips = "aa")] + Afar, - [Custom(Name = "Arabic", ResourceType = typeof(Resources.Language))] - ar = 3, + [Custom(Name = "Afrikaans", Tips = "af")] + Afrikaans, - [Custom(Name = "Spanish", Group = "Website", ResourceType = typeof(Resources.Language))] - es = 4, + [Custom(Name = "Akan", Tips = "ak")] + Akan, - [Custom(Name = "Portuguese", Group = "Website", ResourceType = typeof(Resources.Language))] - pt = 5, + [Custom(Name = "Albanian", Tips = "sq")] + Albanian, - [Custom(Name = "German", ResourceType = typeof(Resources.Language))] - de = 6, + [Custom(Name = "Amharic", Tips = "am")] + Amharic, - [Custom(Name = "Russian", ResourceType = typeof(Resources.Language))] - ru = 7, + [Custom(Name = "Arabic", Tips = "ar")] + Arabic, - [Custom(Name = "Swahili", ResourceType = typeof(Resources.Language))] - sw = 8, + [Custom(Name = "Aragonese", Tips = "an")] + Aragonese, - //todo: maybe wrong - [Custom(Name = "SerboCroatian", ResourceType = typeof(Resources.Language))] - sh = 9, + [Custom(Name = "Armenian", Tips = "hy")] + Armenian, - [Custom(Name = "Italian", ResourceType = typeof(Resources.Language))] - it = 10, + [Custom(Name = "Assamese", Tips = "as")] + Assamese, - [Custom(Name = "Malay", ResourceType = typeof(Resources.Language))] - ms = 11, + [Custom(Name = "Avaric", Tips = "av")] + Avaric, - [Custom(Name = "Tswana", ResourceType = typeof(Resources.Language))] - tn = 12, + [Custom(Name = "Avestan", Tips = "ae")] + Avestan, - [Custom(Name = "Persian", ResourceType = typeof(Resources.Language))] - fa = 13, + [Custom(Name = "Aymara", Tips = "ay")] + Aymara, - [Custom(Name = "Dutch", ResourceType = typeof(Resources.Language))] - nl = 14, + [Custom(Name = "Azerbaijani", Tips = "az")] + Azerbaijani, - [Custom(Name = "Sotho", ResourceType = typeof(Resources.Language))] - st = 15, + [Custom(Name = "Bambara", Tips = "bm")] + Bambara, - [Custom(Name = "Albanian", ResourceType = typeof(Resources.Language))] - sq = 16, + [Custom(Name = "Bashkir", Tips = "ba")] + Bashkir, - [Custom(Name = "StandardChinese", ResourceType = typeof(Resources.Language))] - zh = 17, + [Custom(Name = "Basque", Tips = "eu")] + Basque, - [Custom(Name = "Romanian", ResourceType = typeof(Resources.Language))] - ro = 18, + [Custom(Name = "Belarusian", Tips = "be")] + Belarusian, - //todo: complete the others code iso - [Custom(Name = "Turkish", ResourceType = typeof(Resources.Language))] - Turkish = 19, + [Custom(Name = "Bengali", Tips = "bn")] + Bengali, - [Custom(Name = "Berber", ResourceType = typeof(Resources.Language))] - Berber = 20, + [Custom(Name = "Bislama", Tips = "bi")] + Bislama, - [Custom(Name = "Aymara", ResourceType = typeof(Resources.Language))] - Aymara = 21, + [Custom(Name = "Bosnian", Tips = "bs")] + Bosnian, - [Custom(Name = "Quechua", ResourceType = typeof(Resources.Language))] - Quechua = 22, + [Custom(Name = "Breton", Tips = "br")] + Breton, - [Custom(Name = "RwandaRundi", ResourceType = typeof(Resources.Language))] - RwandaRundi = 23, + [Custom(Name = "Bulgarian", Tips = "bg")] + Bulgarian, - [Custom(Name = "Tigrinya", ResourceType = typeof(Resources.Language))] - Tigrinya = 24, + [Custom(Name = "Burmese", Tips = "my")] + Burmese, - [Custom(Name = "Swati", ResourceType = typeof(Resources.Language))] - Swati = 25, + [Custom(Name = "Catalan", Tips = "ca")] + Catalan, - [Custom(Name = "Greek", ResourceType = typeof(Resources.Language))] - Greek = 26, + [Custom(Name = "Chamorro", Tips = "ch")] + Chamorro, - [Custom(Name = "HindiUrdu", ResourceType = typeof(Resources.Language))] - HindiUrdu = 27, + [Custom(Name = "Chechen", Tips = "ce")] + Chechen, - [Custom(Name = "Chichewa", ResourceType = typeof(Resources.Language))] - Chichewa = 28, + [Custom(Name = "Chichewa", Tips = "ny")] + Chichewa, - [Custom(Name = "Korean", ResourceType = typeof(Resources.Language))] - Korean = 29, + [Custom(Name = "Chinese", Tips = "zh")] + Chinese, - [Custom(Name = "Guarani", ResourceType = typeof(Resources.Language))] - Guarani = 30, + [Custom(Name = "Church Slavonic", Tips = "cu")] + ChurchSlavonic, - [Custom(Name = "Venda", ResourceType = typeof(Resources.Language))] - Venda = 31, + [Custom(Name = "Chuvash", Tips = "cv")] + Chuvash, - [Custom(Name = "Xhosa", ResourceType = typeof(Resources.Language))] - Xhosa = 32, + [Custom(Name = "Cornish", Tips = "kw")] + Cornish, - [Custom(Name = "Tamil", ResourceType = typeof(Resources.Language))] - Tamil = 33, + [Custom(Name = "Corsican", Tips = "co")] + Corsican, - [Custom(Name = "Swedish", ResourceType = typeof(Resources.Language))] - Swedish = 34, + [Custom(Name = "Cree", Tips = "cr")] + Cree, - [Custom(Name = "Armenian", ResourceType = typeof(Resources.Language))] - Armenian = 35, + [Custom(Name = "Croatian", Tips = "hr")] + Croatian, - [Custom(Name = "Somali", ResourceType = typeof(Resources.Language))] - Somali = 36 - } + [Custom(Name = "Czech", Tips = "cs")] + Czech, - public enum LanguageOld - { - [Custom(Name = "Chinês Mandarim")] - MandarinChinese = 1, + [Custom(Name = "Danish", Tips = "da")] + Danish, + + [Custom(Name = "Divehi", Tips = "dv")] + Divehi, + + [Custom(Name = "Dutch", Tips = "nl")] + Dutch, + + [Custom(Name = "Dzongkha", Tips = "dz")] + Dzongkha, + + [Custom(Name = "English", Tips = "en")] + English, + + [Custom(Name = "Esperanto", Tips = "eo")] + Esperanto, + + [Custom(Name = "Estonian", Tips = "et")] + Estonian, + + [Custom(Name = "Ewe", Tips = "ee")] + Ewe, + + [Custom(Name = "Faroese", Tips = "fo")] + Faroese, + + [Custom(Name = "Fijian", Tips = "fj")] + Fijian, + + [Custom(Name = "Finnish", Tips = "fi")] + Finnish, + + [Custom(Name = "French", Tips = "fr")] + French, + + [Custom(Name = "Western Frisian", Tips = "fy")] + WesternFrisian, + + [Custom(Name = "Fulah", Tips = "ff")] + Fulah, + + [Custom(Name = "Gaelic", Tips = "gd")] + Gaelic, + + [Custom(Name = "Galician", Tips = "gl")] + Galician, + + [Custom(Name = "Ganda", Tips = "lg")] + Ganda, + + [Custom(Name = "Georgian", Tips = "ka")] + Georgian, + + [Custom(Name = "German", Tips = "de")] + German, + + [Custom(Name = "Greek", Tips = "el")] + Greek, + + [Custom(Name = "Kalaallisut", Tips = "kl")] + Kalaallisut, + + [Custom(Name = "Guarani", Tips = "gn")] + Guarani, + + [Custom(Name = "Gujarati", Tips = "gu")] + Gujarati, + + [Custom(Name = "Haitian", Tips = "ht")] + Haitian, + + [Custom(Name = "Hausa", Tips = "ha")] + Hausa, + + [Custom(Name = "Hebrew", Tips = "he")] + Hebrew, + + [Custom(Name = "Herero", Tips = "hz")] + Herero, + + [Custom(Name = "Hindi", Tips = "hi")] + Hindi, + + [Custom(Name = "Hiri Motu", Tips = "ho")] + HiriMotu, + + [Custom(Name = "Hungarian", Tips = "hu")] + Hungarian, + + [Custom(Name = "Icelandic", Tips = "is")] + Icelandic, + + [Custom(Name = "Ido", Tips = "io")] + Ido, + + [Custom(Name = "Igbo", Tips = "ig")] + Igbo, + + [Custom(Name = "Indonesian", Tips = "id")] + Indonesian, + + [Custom(Name = "Interlingua", Tips = "ia")] + Interlingua, + + [Custom(Name = "Interlingue", Tips = "ie")] + Interlingue, + + [Custom(Name = "Inuktitut", Tips = "iu")] + Inuktitut, + + [Custom(Name = "Inupiaq", Tips = "ik")] + Inupiaq, + + [Custom(Name = "Irish", Tips = "ga")] + Irish, + + [Custom(Name = "Italian", Tips = "it")] + Italian, + + [Custom(Name = "Japanese", Tips = "ja")] + Japanese, + + [Custom(Name = "Javanese", Tips = "jv")] + Javanese, + + [Custom(Name = "Kannada", Tips = "kn")] + Kannada, + + [Custom(Name = "Kanuri", Tips = "kr")] + Kanuri, + + [Custom(Name = "Kashmiri", Tips = "ks")] + Kashmiri, + + [Custom(Name = "Kazakh", Tips = "kk")] + Kazakh, + + [Custom(Name = "Central Khmer", Tips = "km")] + CentralKhmer, + + [Custom(Name = "Kikuyu", Tips = "ki")] + Kikuyu, + + [Custom(Name = "Kinyarwanda", Tips = "rw")] + Kinyarwanda, + + [Custom(Name = "Kirghiz", Tips = "ky")] + Kirghiz, + + [Custom(Name = "Komi", Tips = "kv")] + Komi, + + [Custom(Name = "Kongo", Tips = "kg")] + Kongo, + + [Custom(Name = "Korean", Tips = "ko")] + Korean, + + [Custom(Name = "Kuanyama", Tips = "kj")] + Kuanyama, + + [Custom(Name = "Kurdish", Tips = "ku")] + Kurdish, + + [Custom(Name = "Lao", Tips = "lo")] + Lao, + + [Custom(Name = "Latin", Tips = "la")] + Latin, - [Custom(Name = "Espanhol")] - Spanish = 2, + [Custom(Name = "Latvian", Tips = "lv")] + Latvian, - [Custom(Name = "Inglês")] - English = 3, + [Custom(Name = "Limburgan", Tips = "li")] + Limburgan, - [Custom(Name = "Hindi")] - Hindi = 4, + [Custom(Name = "Lingala", Tips = "ln")] + Lingala, - [Custom(Name = "Português")] - Portuguese = 5, + [Custom(Name = "Lithuanian", Tips = "lt")] + Lithuanian, - [Custom(Name = "Bengali")] - Bengali = 6, + [Custom(Name = "Luba-Katanga", Tips = "lu")] + LubaKatanga, - [Custom(Name = "Russo")] - Russian = 7, + [Custom(Name = "Luxembourgish", Tips = "lb")] + Luxembourgish, - [Custom(Name = "Japonês")] - Japanese = 8, + [Custom(Name = "Macedonian", Tips = "mk")] + Macedonian, - [Custom(Name = "Punjabi")] - Punjabi = 9, + [Custom(Name = "Malagasy", Tips = "mg")] + Malagasy, - [Custom(Name = "Yue Chinês")] - YueChinese = 10, + [Custom(Name = "Malay", Tips = "ms")] + Malay, - [Custom(Name = "Vietnamita")] - Vietnamese = 11, + [Custom(Name = "Malayalam", Tips = "ml")] + Malayalam, - [Custom(Name = "Marati")] - Marathi = 12, + [Custom(Name = "Maltese", Tips = "mt")] + Maltese, - [Custom(Name = "Telugu")] - Telugu = 13, + [Custom(Name = "Manx", Tips = "gv")] + Manx, - [Custom(Name = "Turco")] - Turkish = 14, + [Custom(Name = "Maori", Tips = "mi")] + Maori, - [Custom(Name = "Wu Chinês")] - WuChinese = 15, + [Custom(Name = "Marathi", Tips = "mr")] + Marathi, - [Custom(Name = "Coreano")] - Korean = 16, + [Custom(Name = "Marshallese", Tips = "mh")] + Marshallese, - [Custom(Name = "Francês")] - French = 17, + [Custom(Name = "Mongolian", Tips = "mn")] + Mongolian, - [Custom(Name = "Alemão")] - German = 18, + [Custom(Name = "Nauru", Tips = "na")] + Nauru, - [Custom(Name = "Tâmil")] - Tamil = 19, + [Custom(Name = "Navajo", Tips = "nv")] + Navajo, - [Custom(Name = "Urdu")] - Urdu = 20, + [Custom(Name = "North Ndebele", Tips = "nd")] + NorthNdebele, - [Custom(Name = "Javanês")] - Javanese = 21, + [Custom(Name = "South Ndebele", Tips = "nr")] + SouthNdebele, - [Custom(Name = "Italiano")] - Italian = 22, + [Custom(Name = "Ndonga", Tips = "ng")] + Ndonga, - [Custom(Name = "Egyptian Arabic")] - EgyptianArabic = 23, + [Custom(Name = "Nepali", Tips = "ne")] + Nepali, - [Custom(Name = "Gujarati")] - Gujarati = 24, + [Custom(Name = "Norwegian", Tips = "no")] + Norwegian, - [Custom(Name = "Iranian Persian")] - IranianPersian = 25, + [Custom(Name = "Norwegian Bokmål", Tips = "nb")] + NorwegianBokmål, - [Custom(Name = "Bhojpuri")] - Bhojpuri = 26, + [Custom(Name = "Norwegian Nynorsk", Tips = "nn")] + NorwegianNynorsk, - [Custom(Name = "Southern Min")] - SouthernMin = 27, + [Custom(Name = "Sichuan Yi", Tips = "ii")] + SichuanYi, - [Custom(Name = "Hakka Chinese")] - HakkaChinese = 28, + [Custom(Name = "Occitan", Tips = "oc")] + Occitan, - [Custom(Name = "Jin Chinese")] - JinChinese = 29, + [Custom(Name = "Ojibwa", Tips = "oj")] + Ojibwa, - [Custom(Name = "Hausa")] - Hausa = 30, + [Custom(Name = "Oriya", Tips = "or")] + Oriya, - [Custom(Name = "Kannada")] - Kannada = 31, + [Custom(Name = "Oromo", Tips = "om")] + Oromo, - [Custom(Name = "Indonésio")] - Indonesian = 32, + [Custom(Name = "Ossetian", Tips = "os")] + Ossetian, - [Custom(Name = "Yoruba")] - Yoruba = 33, + [Custom(Name = "Pali", Tips = "pi")] + Pali, - [Custom(Name = "Polish")] - Polish = 34, + [Custom(Name = "Pashto", Tips = "ps")] + Pashto, - [Custom(Name = "Xiang Chinese")] - XiangChinese = 35, + [Custom(Name = "Persian", Tips = "fa")] + Persian, - [Custom(Name = "Malayalam")] - Malayalam = 36, + [Custom(Name = "Polish", Tips = "pl")] + Polish, - [Custom(Name = "Odia")] - Odia = 37, + [Custom(Name = "Portuguese", Tips = "pt")] + Portuguese, - [Custom(Name = "Maithili")] - Maithili = 38, + [Custom(Name = "Punjabi", Tips = "pa")] + Punjabi, - [Custom(Name = "Sudanese Arabic")] - SudaneseArabic = 39, + [Custom(Name = "Quechua", Tips = "qu")] + Quechua, - [Custom(Name = "Burmese")] - Burmese = 40, + [Custom(Name = "Romanian", Tips = "ro")] + Romanian, - [Custom(Name = "Eastern Punjabi")] - EasternPunjabi = 41, + [Custom(Name = "Romansh", Tips = "rm")] + Romansh, - [Custom(Name = "Sunda")] - Sunda = 42, + [Custom(Name = "Rundi", Tips = "rn")] + Rundi, - [Custom(Name = "Algerian Arabic")] - AlgerianArabic = 43, + [Custom(Name = "Russian", Tips = "ru")] + Russian, - [Custom(Name = "Moroccan Arabic")] - MoroccanArabic = 44, + [Custom(Name = "Northern Sami", Tips = "se")] + NorthernSami, - [Custom(Name = "Ukrainian")] - Ukrainian = 45, + [Custom(Name = "Samoan", Tips = "sm")] + Samoan, - [Custom(Name = "Igbo")] - Igbo = 46, + [Custom(Name = "Sango", Tips = "sg")] + Sango, - [Custom(Name = "Northern Uzbek")] - NorthernUzbek = 47, + [Custom(Name = "Sanskrit", Tips = "sa")] + Sanskrit, - [Custom(Name = "Sindhi")] - Sindhi = 48, + [Custom(Name = "Sardinian", Tips = "sc")] + Sardinian, - [Custom(Name = "North Levantine Arabic")] - NorthLevantineArabic = 49, + [Custom(Name = "Serbian", Tips = "sr")] + Serbian, - [Custom(Name = "Romanian")] - Romanian = 50, + [Custom(Name = "Shona", Tips = "sn")] + Shona, - [Custom(Name = "Tagalog")] - Tagalog = 51, + [Custom(Name = "Sindhi", Tips = "sd")] + Sindhi, - //Dutch 52 + [Custom(Name = "Sinhala", Tips = "si")] + Sinhala, - //Saʽidi Arabic 53 + [Custom(Name = "Slovak", Tips = "sk")] + Slovak, - //Gan Chinese 54 + [Custom(Name = "Slovenian", Tips = "sl")] + Slovenian, - [Custom(Name = "Amharic")] - Amharic = 55, + [Custom(Name = "Somali", Tips = "so")] + Somali, - //Northern Pashto 56 + [Custom(Name = "Southern Sotho", Tips = "st")] + SouthernSotho, - //Magahi 57 + [Custom(Name = "Spanish", Tips = "es")] + Spanish, - [Custom(Name = "Thai")] - Thai = 58, + [Custom(Name = "Sundanese", Tips = "su")] + Sundanese, - //Saraiki 59 + [Custom(Name = "Swahili", Tips = "sw")] + Swahili, - //Khmer 60 + [Custom(Name = "Swati", Tips = "ss")] + Swati, - //Chhattisgarhi 61 + [Custom(Name = "Swedish", Tips = "sv")] + Swedish, - //Somali 62 + [Custom(Name = "Tagalog", Tips = "tl")] + Tagalog, - //Malaysian 63 + [Custom(Name = "Tahitian", Tips = "ty")] + Tahitian, - //Cebuano 64 + [Custom(Name = "Tajik", Tips = "tg")] + Tajik, - //Nepali 65 + [Custom(Name = "Tamil", Tips = "ta")] + Tamil, - //Mesopotamian Arabic 66 + [Custom(Name = "Tatar", Tips = "tt")] + Tatar, - //Assamese 67 + [Custom(Name = "Telugu", Tips = "te")] + Telugu, - //Sinhalese 68 + [Custom(Name = "Thai", Tips = "th")] + Thai, - //Northern Kurdish 69 + [Custom(Name = "Tibetan", Tips = "bo")] + Tibetan, - //Hejazi Arabic 70 + [Custom(Name = "Tigrinya", Tips = "ti")] + Tigrinya, - //Nigerian Fulfulde 71 + [Custom(Name = "Tonga", Tips = "to")] + Tonga, - //Bavarian 72 + [Custom(Name = "Tsonga", Tips = "ts")] + Tsonga, - //South Azerbaijani 73 + [Custom(Name = "Tswana", Tips = "tn")] + Tswana, - //Greek 74 + [Custom(Name = "Turkish", Tips = "tr")] + Turkish, - //Chittagonian 75 + [Custom(Name = "Turkmen", Tips = "tk")] + Turkmen, - //Kazakh 76 + [Custom(Name = "Twi", Tips = "tw")] + Twi, - //Deccan 77 + [Custom(Name = "Uighur", Tips = "ug")] + Uighur, - //Hungarian 78 + [Custom(Name = "Ukrainian", Tips = "uk")] + Ukrainian, - //Kinyarwanda 79 + [Custom(Name = "Urdu", Tips = "ur")] + Urdu, - //Zulu 80 + [Custom(Name = "Uzbek", Tips = "uz")] + Uzbek, - //South Levantine Arabic 81 + [Custom(Name = "Venda", Tips = "ve")] + Venda, - //Tunisian Arabic 82 + [Custom(Name = "Vietnamese", Tips = "vi")] + Vietnamese, - //Sanaani Spoken Arabic 83 + [Custom(Name = "Volapük", Tips = "vo")] + Volapük, - //Northern Min 84 + [Custom(Name = "Walloon", Tips = "wa")] + Walloon, - //Southern Pashto 85 + [Custom(Name = "Welsh", Tips = "cy")] + Welsh, - //Rundi 86 + [Custom(Name = "Wolof", Tips = "wo")] + Wolof, - //Czech 87 + [Custom(Name = "Xhosa", Tips = "xh")] + Xhosa, - //Taʽizzi-Adeni Arabic 88 + [Custom(Name = "Yiddish", Tips = "yi")] + Yiddish, - //Uyghur 89 + [Custom(Name = "Yoruba", Tips = "yo")] + Yoruba, - //Eastern Min 90 + [Custom(Name = "Zhuang", Tips = "za")] + Zhuang, - //Sylheti 91 + [Custom(Name = "Zulu", Tips = "zu")] + Zulu, } } \ No newline at end of file diff --git a/MM.Shared/Enums/Resources/Language.Designer.cs b/MM.Shared/Enums/Resources/Language.Designer.cs deleted file mode 100644 index dd79317..0000000 --- a/MM.Shared/Enums/Resources/Language.Designer.cs +++ /dev/null @@ -1,387 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace MM.Shared.Enums.Resources { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class Language { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Language() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MM.Shared.Enums.Resources.Language", typeof(Language).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Albanian. - /// - public static string Albanian { - get { - return ResourceManager.GetString("Albanian", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Arabic. - /// - public static string Arabic { - get { - return ResourceManager.GetString("Arabic", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Armenian. - /// - public static string Armenian { - get { - return ResourceManager.GetString("Armenian", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Aymara. - /// - public static string Aymara { - get { - return ResourceManager.GetString("Aymara", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Berber. - /// - public static string Berber { - get { - return ResourceManager.GetString("Berber", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Chichewa. - /// - public static string Chichewa { - get { - return ResourceManager.GetString("Chichewa", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Dutch. - /// - public static string Dutch { - get { - return ResourceManager.GetString("Dutch", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to English. - /// - public static string English { - get { - return ResourceManager.GetString("English", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to French. - /// - public static string French { - get { - return ResourceManager.GetString("French", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to German. - /// - public static string German { - get { - return ResourceManager.GetString("German", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Greek. - /// - public static string Greek { - get { - return ResourceManager.GetString("Greek", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Guarani. - /// - public static string Guarani { - get { - return ResourceManager.GetString("Guarani", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Hindi-Urdu. - /// - public static string HindiUrdu { - get { - return ResourceManager.GetString("HindiUrdu", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Italian. - /// - public static string Italian { - get { - return ResourceManager.GetString("Italian", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Korean. - /// - public static string Korean { - get { - return ResourceManager.GetString("Korean", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Malay. - /// - public static string Malay { - get { - return ResourceManager.GetString("Malay", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Persian. - /// - public static string Persian { - get { - return ResourceManager.GetString("Persian", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Portuguese. - /// - public static string Portuguese { - get { - return ResourceManager.GetString("Portuguese", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Quechua. - /// - public static string Quechua { - get { - return ResourceManager.GetString("Quechua", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Romanian. - /// - public static string Romanian { - get { - return ResourceManager.GetString("Romanian", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Russian. - /// - public static string Russian { - get { - return ResourceManager.GetString("Russian", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Rwanda-Rundi. - /// - public static string RwandaRundi { - get { - return ResourceManager.GetString("RwandaRundi", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Serbo-Croatian. - /// - public static string SerboCroatian { - get { - return ResourceManager.GetString("SerboCroatian", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Somali. - /// - public static string Somali { - get { - return ResourceManager.GetString("Somali", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Sotho. - /// - public static string Sotho { - get { - return ResourceManager.GetString("Sotho", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Spanish. - /// - public static string Spanish { - get { - return ResourceManager.GetString("Spanish", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Standard Chinese. - /// - public static string StandardChinese { - get { - return ResourceManager.GetString("StandardChinese", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Swahili. - /// - public static string Swahili { - get { - return ResourceManager.GetString("Swahili", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Swati. - /// - public static string Swati { - get { - return ResourceManager.GetString("Swati", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Swedish. - /// - public static string Swedish { - get { - return ResourceManager.GetString("Swedish", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Tamil. - /// - public static string Tamil { - get { - return ResourceManager.GetString("Tamil", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Tigrinya. - /// - public static string Tigrinya { - get { - return ResourceManager.GetString("Tigrinya", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Tswana. - /// - public static string Tswana { - get { - return ResourceManager.GetString("Tswana", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Turkish. - /// - public static string Turkish { - get { - return ResourceManager.GetString("Turkish", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Venda. - /// - public static string Venda { - get { - return ResourceManager.GetString("Venda", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Xhosa. - /// - public static string Xhosa { - get { - return ResourceManager.GetString("Xhosa", resourceCulture); - } - } - } -} diff --git a/MM.Shared/Enums/Resources/Language.es.resx b/MM.Shared/Enums/Resources/Language.es.resx deleted file mode 100644 index 930e8c3..0000000 --- a/MM.Shared/Enums/Resources/Language.es.resx +++ /dev/null @@ -1,228 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Albanés - - - Árabe - - - Armenio - - - Aymara - - - Bereber - - - Chichewa - - - Holandés - - - Inglés - - - Francés - - - Alemán - - - Griego - - - Guaraní - - - Hindi-Urdu - - - Italiano - - - Coreano - - - Malayo - - - Persa - - - Portugués - - - Quechua - - - Rumano - - - Ruso - - - Ruanda-Rundi - - - Serbocroata - - - Somalí - - - Sotho - - - Español - - - Chino estándar - - - Swahili - - - Swati - - - Sueco - - - Tamil - - - Tigriña - - - Setswana - - - Turco - - - Venda - - - Xosa - - \ No newline at end of file diff --git a/MM.Shared/Enums/Resources/Language.pt.resx b/MM.Shared/Enums/Resources/Language.pt.resx deleted file mode 100644 index ce67429..0000000 --- a/MM.Shared/Enums/Resources/Language.pt.resx +++ /dev/null @@ -1,228 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Albanês - - - Árabe - - - Armênio - - - Aymara - - - Berber - - - Chichewa - - - Holandês - - - Inglês - - - Francês - - - Alemão - - - Grego - - - Guarani - - - Hindi-Urdu - - - Italiano - - - Coreano - - - Malaio - - - Persa - - - Português - - - Quechua - - - Romeno - - - Russo - - - Rwanda-Rundi - - - Servo-Croata - - - Somali - - - Sotho - - - Espanhol - - - Chinês Padrão - - - Suaíli - - - Swati - - - Sueco - - - Tâmil - - - Tigrinya - - - Tswana - - - Turco - - - Venda - - - Xhosa - - \ No newline at end of file diff --git a/MM.Shared/Enums/Resources/Language.resx b/MM.Shared/Enums/Resources/Language.resx deleted file mode 100644 index 979c12b..0000000 --- a/MM.Shared/Enums/Resources/Language.resx +++ /dev/null @@ -1,228 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Albanian - - - Arabic - - - Armenian - - - Aymara - - - Berber - - - Chichewa - - - Dutch - - - English - - - French - - - German - - - Greek - - - Guarani - - - Hindi-Urdu - - - Italian - - - Korean - - - Malay - - - Persian - - - Portuguese - - - Quechua - - - Romanian - - - Russian - - - Rwanda-Rundi - - - Serbo-Croatian - - - Somali - - - Sotho - - - Spanish - - - Standard Chinese - - - Swahili - - - Swati - - - Swedish - - - Tamil - - - Tigrinya - - - Tswana - - - Turkish - - - Venda - - - Xhosa - - \ No newline at end of file diff --git a/MM.Shared/MM.Shared.csproj b/MM.Shared/MM.Shared.csproj index 6af483b..df106c4 100644 --- a/MM.Shared/MM.Shared.csproj +++ b/MM.Shared/MM.Shared.csproj @@ -13,8 +13,8 @@ - - + + @@ -147,11 +147,6 @@ True Intentions.resx - - True - True - Language.resx - True True @@ -356,10 +351,6 @@ PublicResXFileCodeGenerator Intentions.Designer.cs - - PublicResXFileCodeGenerator - Language.Designer.cs - PublicResXFileCodeGenerator LeisureActivities.Designer.cs diff --git a/MM.Shared/Models/Auth/ClienteLogin.cs b/MM.Shared/Models/Auth/ClienteLogin.cs index e098e02..3c236bd 100644 --- a/MM.Shared/Models/Auth/ClienteLogin.cs +++ b/MM.Shared/Models/Auth/ClienteLogin.cs @@ -19,7 +19,6 @@ public override void Initialize(string userId) public override bool HasValidData() { if (string.IsNullOrEmpty(UserId)) return false; - if (UserId != Key) return false; return true; } diff --git a/MM.Shared/Models/Auth/ClientePrincipal.cs b/MM.Shared/Models/Auth/ClientePrincipal.cs index 4ae85a5..3d28f1f 100644 --- a/MM.Shared/Models/Auth/ClientePrincipal.cs +++ b/MM.Shared/Models/Auth/ClientePrincipal.cs @@ -30,7 +30,6 @@ public override bool HasValidData() if (string.IsNullOrEmpty(IdentityProvider)) return false; if (string.IsNullOrEmpty(UserDetails)) return false; if (UserRoles.Length == 0) return false; - if (UserId != Key) return false; return true; } diff --git a/MM.Shared/Models/GoogleJson.cs b/MM.Shared/Models/GoogleJson.cs new file mode 100644 index 0000000..8ffe681 --- /dev/null +++ b/MM.Shared/Models/GoogleJson.cs @@ -0,0 +1,82 @@ +namespace MM.Shared.Models +{ + public class AddressComponent + { + public string? long_name { get; set; } + public string? short_name { get; set; } + public List types { get; set; } = []; + } + + public class Bounds + { + public Northeast? northeast { get; set; } + public Southwest? southwest { get; set; } + } + + public class Geometry + { + public Location? location { get; set; } + public string? location_type { get; set; } + public Viewport? viewport { get; set; } + public Bounds? bounds { get; set; } + } + + public class Location + { + public double lat { get; set; } + public double lng { get; set; } + } + + public class Northeast + { + public double lat { get; set; } + public double lng { get; set; } + } + + public class PlusCode + { + public string? compound_code { get; set; } + public string? global_code { get; set; } + } + + public class Result + { + public List address_components { get; set; } = []; + public string? formatted_address { get; set; } + public Geometry? geometry { get; set; } + public string? place_id { get; set; } + public PlusCode? plus_code { get; set; } + public List types { get; set; } = []; + + public string GetLocation() + { + var country = address_components.Find(f => f.types.Contains("country"))?.long_name; + var area_level_1 = address_components.Find(f => f.types.Contains("administrative_area_level_1"))?.long_name; //state or county + var area_level_2 = address_components.Find(f => f.types.Contains("administrative_area_level_2"))?.long_name; //city + + if (area_level_2.Empty()) + return $"{country} - {area_level_1}"; + else + return $"{country} - {area_level_1} - {area_level_2}"; + } + } + + public class GoogleJson + { + public PlusCode? plus_code { get; set; } + public List results { get; set; } = []; + public string? status { get; set; } + } + + public class Southwest + { + public double lat { get; set; } + public double lng { get; set; } + } + + public class Viewport + { + public Northeast? northeast { get; set; } + public Southwest? southwest { get; set; } + } +} \ No newline at end of file diff --git a/MM.Shared/Models/JavascriptVM.cs b/MM.Shared/Models/HereJson.cs similarity index 57% rename from MM.Shared/Models/JavascriptVM.cs rename to MM.Shared/Models/HereJson.cs index 9ca299d..006c98f 100644 --- a/MM.Shared/Models/JavascriptVM.cs +++ b/MM.Shared/Models/HereJson.cs @@ -8,7 +8,7 @@ public class GeoLocation } /// - /// OBS: O idioma dos textos recuperados é o mesmo da localização + /// note: language is the same as the searched location /// public class HereAddress { @@ -18,18 +18,12 @@ public class HereAddress public string? county { get; set; } public string? city { get; set; } - /// - /// Recupera a localização contendo as seguintes informaçoes: country, state, county, city - /// Caso county e city sejam iguais, só retornará um deles - /// - /// public string GetLocation() { - var locations = new List() { countryName, state }; + if (countryName.Empty()) throw new NotificationException("country not found"); + if (city.Empty()) throw new NotificationException("city not found"); - locations.AddRange(new[] { county, city }.Distinct()); - - return string.Join(" - ", locations.Where(w => !string.IsNullOrEmpty(w))); + return $"{countryName} - {state ?? county ?? countryName} - {city}"; } } diff --git a/MM.Shared/Models/Profile/ProfileModel.cs b/MM.Shared/Models/Profile/ProfileModel.cs index c8c4c9b..776dce8 100644 --- a/MM.Shared/Models/Profile/ProfileModel.cs +++ b/MM.Shared/Models/Profile/ProfileModel.cs @@ -24,13 +24,13 @@ public ProfileModel() : base(DocumentType.Profile) public string? Location { get; set; } [Custom(Name = "Languages_Name", Description = "Languages_Description", FieldInfo = "Dizem que uma boa comunicação é a chave para qualquer relacionamento duradouro e bem-sucedido. É absolutamente essencial que duas pessoas compartilhem seus sentimentos, expressem seus pensamentos e, talvez o mais importante, ouçam atentamente uma à outra. Infelizmente, no mundo acelerado e agitado de hoje, muitos casais não encontram tempo para sentar e ter uma conversa significativa um com o outro. Telefonemas e mensagens de texto substituíram os bate-papos pessoais entre duas pessoas. A falta de comunicação adequada é uma das principais razões pelas quais muitos relacionamentos não duram tanto quanto deveriam. Tendo tudo isso em mente, é realmente uma boa ideia você namorar uma pessoa que não fala a mesma língua que você?", ResourceType = typeof(Resources.ProfileBasicModel))] - public IReadOnlyList Languages { get; set; } = []; + public HashSet Languages { get; set; } = []; [Custom(Name = "CurrentSituation_Name", ResourceType = typeof(Resources.ProfileBasicModel))] public CurrentSituation? CurrentSituation { get; set; } [Custom(Name = "Intentions_Name", Description = "Intentions_Description", FieldInfo = "De acordo com a psicoterapeuta e conselheira de casais de Sydney, Annie Gurton, ser honesto e claro sobre o que você está procurando em um relacionamento é para o benefício de ambos. E para a melhor chance de sucesso, ela acredita que vocês dois devem ter as mesmas intenções. \"É tudo uma questão de fazer um jogo\", explica ela. \"Algumas pessoas querem um relacionamento casual, talvez com outros parceiros ou talvez sem qualquer conversa de compromisso, e eles são melhores com alguém que pensa da mesma maneira e não com alguém que procura um compromisso de longo prazo.\"", ResourceType = typeof(Resources.ProfileBasicModel))] - public IReadOnlyList Intentions { get; set; } = []; + public HashSet Intentions { get; set; } = []; [Custom(Name = "BiologicalSex_Name", ResourceType = typeof(Resources.ProfileBasicModel))] public BiologicalSex? BiologicalSex { get; set; } @@ -78,7 +78,7 @@ public ProfileModel() : base(DocumentType.Profile) FieldInfo = "Todos nós desejamos e merecemos ter relacionamentos significativos onde nos sentimos amados e apreciados. Essa necessidade também é sentida por pessoas com deficiência. Algumas pessoas podem se surpreender com isso porque assumem que pessoas com deficiência não namoram, casam ou desejam relacionamentos íntimos. Mas, isso não é verdade. De fato, não há diferença entre a necessidade e o desejo de pessoas com deficiência por relacionamentos saudáveis e felizes e os de pessoas sem deficiência.", Tips = "Compartilhe seus sentimentos e preocupações|Qualquer deficiência pode ter um impacto emocional significativo em uma pessoa. Mas isso pode ser particularmente o caso se o parceiro for fisicamente apto e não puder se relacionar totalmente com o que está passando.|Esteja ciente dos efeitos emocionais em seu parceiro|As responsabilidades adicionais que vêm com viver ou namorar uma pessoa com deficiência podem sobrecarregar seu parceiro às vezes. Isso também é completamente normal.|Fale sobre suas finanças|Além dos efeitos emocionais de uma deficiência, é provável que tenha um impacto em suas finanças. Contas médicas, adaptações em sua casa e equipamentos para deficientes não são baratos.|Seja íntimo de qualquer maneira que puder|Uma deficiência ou condição de saúde pode alterar a forma como você faz sexo ou é íntimo. Também pode significar que você tem preocupações com a imagem corporal ou falta de confiança. Mas nada disso significa que você não pode desfrutar de uma vida sexual, seja lá o que for para você.|Encontre coisas para fazer juntos|Nenhum relacionamento pode sobreviver se você não puder se adaptar a uma situação e um ao outro. Sejamos fisicamente aptos ou deficientes, nossas circunstâncias de vida estão mudando constantemente.|Não desista|Mesmo quando você estiver se sentindo deprimido, deprimido ou com dor, ou quase pronto para desistir de tudo, tenha certeza de que dias melhores virão.", ResourceType = typeof(Resources.ProfileBioModel))] - public IReadOnlyList Disabilities { get; set; } = []; + public HashSet Disabilities { get; set; } = []; #endregion BIO @@ -168,33 +168,36 @@ public ProfileModel() : base(DocumentType.Profile) ResourceType = typeof(Resources.ProfileLifestyleModel))] public SexPersonality? SexPersonality { get; set; } + [Custom(Name = "SexPersonalityPreferences_Name", Description = "SexPersonalityPreferences_Description", ResourceType = typeof(Resources.ProfileLifestyleModel))] + public HashSet SexPersonalityPreference { get; set; } = []; + #endregion PERSONALITY #region INTEREST [Custom(Name = "Food", ResourceType = typeof(Resources.ProfileInterestModel))] - public IReadOnlyList Food { get; set; } = []; + public HashSet Food { get; set; } = []; [Custom(Name = "Vacation", ResourceType = typeof(Resources.ProfileInterestModel))] - public IReadOnlyList Vacation { get; set; } = []; + public HashSet Vacation { get; set; } = []; [Custom(Name = "Sports", ResourceType = typeof(Resources.ProfileInterestModel))] - public IReadOnlyList Sports { get; set; } = []; + public HashSet Sports { get; set; } = []; [Custom(Name = "LeisureActivities", ResourceType = typeof(Resources.ProfileInterestModel))] - public IReadOnlyList LeisureActivities { get; set; } = []; + public HashSet LeisureActivities { get; set; } = []; [Custom(Name = "MusicGenre", ResourceType = typeof(Resources.ProfileInterestModel))] - public IReadOnlyList MusicGenre { get; set; } = []; + public HashSet MusicGenre { get; set; } = []; [Custom(Name = "MovieGenre", ResourceType = typeof(Resources.ProfileInterestModel))] - public IReadOnlyList MovieGenre { get; set; } = []; + public HashSet MovieGenre { get; set; } = []; [Custom(Name = "TVGenre", ResourceType = typeof(Resources.ProfileInterestModel))] - public IReadOnlyList TVGenre { get; set; } = []; + public HashSet TVGenre { get; set; } = []; [Custom(Name = "ReadingGenre", ResourceType = typeof(Resources.ProfileInterestModel))] - public IReadOnlyList ReadingGenre { get; set; } = []; + public HashSet ReadingGenre { get; set; } = []; #endregion INTEREST diff --git a/MM.Shared/Models/Profile/ProfilePreferenceModel.cs b/MM.Shared/Models/Profile/ProfilePreferenceModel.cs index 26a5d38..dd0f843 100644 --- a/MM.Shared/Models/Profile/ProfilePreferenceModel.cs +++ b/MM.Shared/Models/Profile/ProfilePreferenceModel.cs @@ -11,29 +11,29 @@ public class ProfilePreferenceModel public Change Change { get; set; } [Custom(Name = "Languages", Description = "Languages_Description", ResourceType = typeof(Resources.ProfilePreferenceModel))] - public IReadOnlyList Languages { get; set; } = []; + public HashSet Languages { get; set; } = []; [Custom(Name = "CurrentSituation", ResourceType = typeof(Resources.ProfilePreferenceModel))] - public IReadOnlyList CurrentSituation { get; set; } = []; + public HashSet CurrentSituation { get; set; } = []; [Custom(Name = "BiologicalSex", ResourceType = typeof(Resources.ProfilePreferenceModel))] - public IReadOnlyList BiologicalSex { get; set; } = []; + public HashSet BiologicalSex { get; set; } = []; [Custom(Name = "GenderIdentity", ResourceType = typeof(Resources.ProfilePreferenceModel))] - public IReadOnlyList GenderIdentity { get; set; } = []; + public HashSet GenderIdentity { get; set; } = []; [Custom(Name = "SexualOrientation", ResourceType = typeof(Resources.ProfilePreferenceModel))] - public IReadOnlyList SexualOrientation { get; set; } = []; + public HashSet SexualOrientation { get; set; } = []; #endregion BASIC #region BIO [Custom(Name = "RaceCategory", ResourceType = typeof(Resources.ProfilePreferenceModel))] - public IReadOnlyList RaceCategory { get; set; } = []; + public HashSet RaceCategory { get; set; } = []; [Custom(Name = "BodyMass", ResourceType = typeof(Resources.ProfilePreferenceModel))] - public IReadOnlyList BodyMass { get; set; } = []; + public HashSet BodyMass { get; set; } = []; [Custom(Name = "MinimalAge", ResourceType = typeof(Resources.ProfilePreferenceModel))] public int MinimalAge { get; set; } @@ -48,51 +48,44 @@ public class ProfilePreferenceModel public Height? MaxHeight { get; set; } [Custom(Name = "Neurodiversities", ResourceType = typeof(Resources.ProfilePreferenceModel))] - public IReadOnlyList Neurodiversities { get; set; } = []; + public HashSet Neurodiversities { get; set; } = []; [Custom(Name = "Disabilities", ResourceType = typeof(Resources.ProfilePreferenceModel))] - public IReadOnlyList Disabilities { get; set; } = []; + public HashSet Disabilities { get; set; } = []; #endregion BIO #region LIFESTYLE [Custom(Name = "Drink_Name", ResourceType = typeof(Resources.ProfileLifestyleModel))] - public IReadOnlyList Drink { get; set; } = []; + public HashSet Drink { get; set; } = []; [Custom(Name = "Smoke_Name", ResourceType = typeof(Resources.ProfileLifestyleModel))] - public IReadOnlyList Smoke { get; set; } = []; + public HashSet Smoke { get; set; } = []; [Custom(Name = "Diet_Name", Description = "Diet_Description", ResourceType = typeof(Resources.ProfileLifestyleModel))] - public IReadOnlyList Diet { get; set; } = []; + public HashSet Diet { get; set; } = []; [Custom(Name = "HaveChildren_Name", ResourceType = typeof(Resources.ProfileLifestyleModel))] - public IReadOnlyList HaveChildren { get; set; } = []; + public HashSet HaveChildren { get; set; } = []; [Custom(Name = "WantChildren_Name", ResourceType = typeof(Resources.ProfileLifestyleModel))] - public IReadOnlyList WantChildren { get; set; } = []; + public HashSet WantChildren { get; set; } = []; [Custom(Name = "EducationLevel_Name", ResourceType = typeof(Resources.ProfileLifestyleModel))] - public IReadOnlyList EducationLevel { get; set; } = []; + public HashSet EducationLevel { get; set; } = []; [Custom(Name = "CareerCluster_Name", ResourceType = typeof(Resources.ProfileLifestyleModel))] - public IReadOnlyList CareerCluster { get; set; } = []; + public HashSet CareerCluster { get; set; } = []; [Custom(Name = "Religion_Name", ResourceType = typeof(Resources.ProfileLifestyleModel))] - public IReadOnlyList Religion { get; set; } = []; + public HashSet Religion { get; set; } = []; [Custom(Name = "Travel Frequency")] - public IReadOnlyList TravelFrequency { get; set; } = []; + public HashSet TravelFrequency { get; set; } = []; #endregion LIFESTYLE - #region PERSONALITY - - [Custom(Name = "SexPersonalityPreferences_Name", Description = "SexPersonalityPreferences_Description", ResourceType = typeof(Resources.ProfileLifestyleModel))] - public IReadOnlyList SexPersonality { get; set; } = []; - - #endregion PERSONALITY - public void UpdateData(ProfilePreferenceModel vm) { //BASIC @@ -121,8 +114,6 @@ public void UpdateData(ProfilePreferenceModel vm) CareerCluster = vm.CareerCluster; Religion = vm.Religion; TravelFrequency = vm.TravelFrequency; - //PERSONALITY - SexPersonality = vm.SexPersonality; } } } \ No newline at end of file diff --git a/MM.Shared/Models/Profile/Resources/ProfileLifestyleModel.Designer.cs b/MM.Shared/Models/Profile/Resources/ProfileLifestyleModel.Designer.cs index 818674e..fd4d175 100644 --- a/MM.Shared/Models/Profile/Resources/ProfileLifestyleModel.Designer.cs +++ b/MM.Shared/Models/Profile/Resources/ProfileLifestyleModel.Designer.cs @@ -223,7 +223,7 @@ public static string SexPersonalityPreferences_Description { } /// - /// Looks up a localized string similar to Sexual Personality. + /// Looks up a localized string similar to Sexual Personality (preferences). /// public static string SexPersonalityPreferences_Name { get { diff --git a/MM.Shared/Models/Profile/Resources/ProfileLifestyleModel.es.resx b/MM.Shared/Models/Profile/Resources/ProfileLifestyleModel.es.resx index a3e03a4..eb5ef29 100644 --- a/MM.Shared/Models/Profile/Resources/ProfileLifestyleModel.es.resx +++ b/MM.Shared/Models/Profile/Resources/ProfileLifestyleModel.es.resx @@ -165,9 +165,6 @@ A diferencia de otras personalidades, la compatibilidad de esta es una preferencia personal. - - Personalidad sexual - Si tiene alguna duda, puede realizar una prueba en el sitio web original (solo en inglés) @@ -186,4 +183,7 @@ Quiero hijos + + Personalidad sexual (preferencias) + \ No newline at end of file diff --git a/MM.Shared/Models/Profile/Resources/ProfileLifestyleModel.pt.resx b/MM.Shared/Models/Profile/Resources/ProfileLifestyleModel.pt.resx index b87042c..cd5bd73 100644 --- a/MM.Shared/Models/Profile/Resources/ProfileLifestyleModel.pt.resx +++ b/MM.Shared/Models/Profile/Resources/ProfileLifestyleModel.pt.resx @@ -165,9 +165,6 @@ Diferentemente das outras personalidades, a compatibilidade desta é uma preferência pessoal. - - Personalidade Sexual - Caso tenha dúvidas, poderá fazer um teste no site original (somente em inglês) @@ -186,4 +183,7 @@ Quer Filho(s) + + Personalidade sexual (preferências) + \ No newline at end of file diff --git a/MM.Shared/Models/Profile/Resources/ProfileLifestyleModel.resx b/MM.Shared/Models/Profile/Resources/ProfileLifestyleModel.resx index 66aba6a..20d6691 100644 --- a/MM.Shared/Models/Profile/Resources/ProfileLifestyleModel.resx +++ b/MM.Shared/Models/Profile/Resources/ProfileLifestyleModel.resx @@ -166,7 +166,7 @@ Unlike other personalities, this one's compatibility is a personal preference. - Sexual Personality + Sexual Personality (preferences) If you have any doubts, you can take a test on the original website (English only) diff --git a/MM.Shared/Models/Support/EmailDocument.cs b/MM.Shared/Models/Support/EmailDocument.cs index 4002f85..23b2398 100644 --- a/MM.Shared/Models/Support/EmailDocument.cs +++ b/MM.Shared/Models/Support/EmailDocument.cs @@ -8,7 +8,7 @@ public EmailDocument() { } - public EmailDocument(string key) : base(key, key) + public EmailDocument(string id) : base(id) { } diff --git a/MM.Shared/Models/Support/TicketModel.cs b/MM.Shared/Models/Support/TicketModel.cs index b0e0705..6c9b8a0 100644 --- a/MM.Shared/Models/Support/TicketModel.cs +++ b/MM.Shared/Models/Support/TicketModel.cs @@ -26,7 +26,9 @@ public TicketModel() : base(DocumentType.Ticket) public TicketStatus TicketStatus { get; set; } = TicketStatus.New; [Custom(Name = "Total de Votos")] - public int TotalVotes { get; set; } + public List Votes { get; set; } = []; + + public int TotalVotes => Votes.Sum(s => s.VoteType == VoteType.MinusOne ? -1 : 1); public void ChangeStatus(TicketStatus ticketStatus) { @@ -35,7 +37,7 @@ public void ChangeStatus(TicketStatus ticketStatus) Update(); } - public void Initialize(string? idUserOwner) + public new void Initialize(string? idUserOwner) { if (string.IsNullOrEmpty(idUserOwner)) throw new ArgumentNullException(nameof(idUserOwner)); @@ -43,15 +45,12 @@ public void Initialize(string? idUserOwner) var id = Guid.NewGuid().ToString(); - base.Initialize(id, id); + base.Initialize(id); } - public void Vote(VoteType voteType) + public void Vote(string userId, VoteType voteType) { - if (voteType == VoteType.PlusOne) - TotalVotes++; - else - TotalVotes--; + Votes.Add(new TicketVote { IdVotedUser = userId, VoteType = voteType }); Update(); } @@ -72,6 +71,13 @@ public override bool HasValidData() } } + public class TicketVote + { + public string? IdVotedUser { get; set; } + + public VoteType VoteType { get; set; } + } + public enum TicketType { [Custom(Name = "BugReport", ResourceType = typeof(Resources.TicketType))] @@ -101,4 +107,10 @@ public enum TicketStatus [Custom(Name = "Declined", ResourceType = typeof(Resources.TicketStatus))] Declined = 6 } + + public enum VoteType + { + MinusOne = -1, + PlusOne = 1 + } } \ No newline at end of file diff --git a/MM.Shared/Models/Support/TicketVoteModel.cs b/MM.Shared/Models/Support/TicketVoteModel.cs deleted file mode 100644 index f9e04b7..0000000 --- a/MM.Shared/Models/Support/TicketVoteModel.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace MM.Shared.Models.Support -{ - public class TicketVoteModel : ProtectedMainDocument - { - public TicketVoteModel() : base(DocumentType.TicketVote) - { - } - - public string? IdVotedUser { get; set; } - - public VoteType VoteType { get; set; } - - public override void Initialize(string id, string key) - { - base.Initialize(Guid.NewGuid().ToString(), key); - } - - public override bool HasValidData() - { - return !string.IsNullOrEmpty(IdVotedUser); - } - - public override bool Equals(object? obj) - { - return obj is TicketVoteModel q && q.Id == Id; - } - - public override int GetHashCode() - { - return Id?.GetHashCode() ?? 0; - } - } - - public enum VoteType - { - MinusOne = -1, - PlusOne = 1 - } -} \ No newline at end of file diff --git a/MM.Shared/Models/Support/UpdateModel.cs b/MM.Shared/Models/Support/UpdateModel.cs index 49c32ba..66a395c 100644 --- a/MM.Shared/Models/Support/UpdateModel.cs +++ b/MM.Shared/Models/Support/UpdateModel.cs @@ -1,5 +1,4 @@ using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; namespace MM.Shared.Models.Support { @@ -7,7 +6,6 @@ public class UpdateModel : ProtectedMainDocument { public UpdateModel() : base(DocumentType.Update) { - IsNew = Date > DateTime.Now.AddMonths(-3); } [Required] @@ -20,14 +18,11 @@ public UpdateModel() : base(DocumentType.Update) public DateTime Date { get; set; } = DateTime.Now; - [NotMapped] - public bool IsNew { get; set; } - public void Initialize() { var id = Guid.NewGuid().ToString(); - base.Initialize(id, id); + base.Initialize(id); } public override bool HasValidData() diff --git a/MM.WEB/Core/AffinityCore.cs b/MM.WEB/Core/AffinityCore.cs index 1d40092..57615e1 100644 --- a/MM.WEB/Core/AffinityCore.cs +++ b/MM.WEB/Core/AffinityCore.cs @@ -26,7 +26,7 @@ public static List GetAffinity(ProfileModel? user, ProfileModel? vie new(Section.Bio, CompatibilityItem.BodyMass, GetBodyMass(user.Preference).IsMatch(view.BodyMass.ToArray())), new(Section.Bio, CompatibilityItem.Age, GetAge(user, user.Preference).IsRangeMatch(view.Age.ToArray())), new(Section.Bio, CompatibilityItem.Zodiac, GetZodiac(user).IsMatch(view.Zodiac.ToArray())), - new(Section.Bio, CompatibilityItem.Height, GetHeight(user, user.Preference).Select(s => (int)s).ToArray().IsRangeMatch(((int?)view.Height).ToArray())), + new(Section.Bio, CompatibilityItem.Height, GetHeight(user, user.Preference).Select(s => (int)s).IsRangeMatch(((int?)view.Height).ToArray())), new(Section.Bio, CompatibilityItem.Neurodiversity, GetNeurodiversity(user.Preference).IsMatch(view.Neurodiversity.ToArray())), new(Section.Bio, CompatibilityItem.Disabilities, GetDisability(user.Preference).IsMatch(view.Disabilities)), @@ -47,7 +47,7 @@ public static List GetAffinity(ProfileModel? user, ProfileModel? vie new(Section.Personality, CompatibilityItem.RelationshipPersonality, GetRelationshipPersonality(user).IsMatch(view.RelationshipPersonality.ToArray(), true)), new(Section.Personality, CompatibilityItem.MyersBriggsTypeIndicator, GetMyersBriggsTypeIndicator(user).IsMatch(view.MBTI.ToArray(), true)), new(Section.Personality, CompatibilityItem.LoveLanguage, GetLoveLanguage(user).IsMatch(view.LoveLanguage.ToArray(), true)), - new(Section.Personality, CompatibilityItem.SexPersonality, GetSexPersonality(user, user.Preference).IsMatch(view.SexPersonality.ToArray(), true)), + new(Section.Personality, CompatibilityItem.SexPersonality, GetSexPersonality(user).IsMatch(view.SexPersonality.ToArray(), true)), //INTEREST - COMPATIBILIDADE DE PERFIL (UMA OPÇAO IGUAL JÁ INDICA COMPATIBILIDADE) new(Section.Interest, CompatibilityItem.Food, GetFood(user).IsMatch(view.Food)), @@ -63,38 +63,38 @@ public static List GetAffinity(ProfileModel? user, ProfileModel? vie return obj; } - public static string[] ToArray(this string item) + public static HashSet ToArray(this string item) { return [item]; } - public static T[] ToArray(this T item) where T : struct + public static HashSet ToArray(this T item) where T : struct { return [item]; } - public static T[] ToArray(this T? item) where T : struct + public static HashSet ToArray(this T? item) where T : struct { if (item.HasValue) return item.Value.ToArray(); else return []; } - private static bool IsMatch(this IReadOnlyList preferences, IReadOnlyList view, bool force = false) + private static bool IsMatch(this HashSet preferences, HashSet view, bool force = false) { - if (force && !preferences.Any()) return false; //if preferences is required - if (!preferences.Any()) return true; //if preferences are empty then accept all - if (!view.Any()) return false; //if the preference is not empty and the view is empty then it does not accept anything + if (force && preferences.Count == 0) return false; //if preferences is required + if (preferences.Count == 0) return true; //if preferences are empty then accept all + if (view.Count == 0) return false; //if the preference is not empty and the view is empty then it does not accept anything return preferences.Intersect(view).Any(); } - private static bool IsRangeMatch(this IReadOnlyList preferences, IReadOnlyList view) + private static bool IsRangeMatch(this IEnumerable preferences, IEnumerable view) { if (!preferences.Any()) return true; //if preferences are empty then accept all if (!view.Any()) return false; //if the preference is not empty and the view is empty then it does not accept anything - if (preferences.Count != 2) throw new InvalidOperationException("preferences.Count != 2"); + if (preferences.Count() != 2) throw new InvalidOperationException("preferences.Count != 2"); - return preferences[0] <= view[0] && view[0] <= preferences[1]; + return preferences.First() <= view.First() && view.First() <= preferences.Last(); } #region BASIC @@ -113,34 +113,34 @@ public static string GetLocation(ProfileModel user) } ?? ""; } - public static IReadOnlyList GetLanguages(ProfileModel user, ProfilePreferenceModel? pref = null) + public static HashSet GetLanguages(ProfileModel user, ProfilePreferenceModel? pref = null) { - if (pref != null && pref.Languages.Any()) return pref.Languages; - else if (user.Languages.Any()) return user.Languages; + if (pref != null && pref.Languages.Count != 0) return pref.Languages; + else if (user.Languages.Count != 0) return user.Languages; else return []; } - public static IReadOnlyList GetCurrentSituation(ProfileModel user, ProfilePreferenceModel? pref = null) + public static HashSet GetCurrentSituation(ProfileModel user, ProfilePreferenceModel? pref = null) { - CurrentSituation[] selected; - if (pref != null && pref.CurrentSituation.Any()) selected = pref.CurrentSituation.ToArray(); + HashSet selected; + if (pref != null && pref.CurrentSituation.Count != 0) selected = pref.CurrentSituation; else if (user.CurrentSituation.HasValue) selected = user.CurrentSituation.ToArray(); else selected = []; - if (selected.Length == 1 && selected.First() == CurrentSituation.Single) + if (selected.Count == 1 && selected.First() == CurrentSituation.Single) return selected; else return []; } - public static IReadOnlyList GetIntentions(ProfileModel user) + public static HashSet GetIntentions(ProfileModel user) { return user.Intentions; } - public static IReadOnlyList GetBiologicalSex(ProfileModel user, ProfilePreferenceModel? pref = null) + public static HashSet GetBiologicalSex(ProfileModel user, ProfilePreferenceModel? pref = null) { - if (pref != null && pref.BiologicalSex.Any()) + if (pref != null && pref.BiologicalSex.Count != 0) { return pref.BiologicalSex; } @@ -178,9 +178,9 @@ public static IReadOnlyList GetBiologicalSex(ProfileModel user, P } } - public static IReadOnlyList GetGenderIdentity(ProfileModel user, ProfilePreferenceModel? pref = null) + public static HashSet GetGenderIdentity(ProfileModel user, ProfilePreferenceModel? pref = null) { - if (pref != null && pref.GenderIdentity.Any()) + if (pref != null && pref.GenderIdentity.Count != 0) { return pref.GenderIdentity; } @@ -197,9 +197,9 @@ public static IReadOnlyList GetGenderIdentity(ProfileModel user, } } - public static IReadOnlyList GetSexualOrientation(ProfileModel user, ProfilePreferenceModel? pref = null) + public static HashSet GetSexualOrientation(ProfileModel user, ProfilePreferenceModel? pref = null) { - if (pref != null && pref.SexualOrientation.Any()) + if (pref != null && pref.SexualOrientation.Count != 0) { return pref.SexualOrientation; } @@ -207,7 +207,7 @@ public static IReadOnlyList GetSexualOrientation(ProfileModel { return user.SexualOrientation switch { - SexualOrientation.Heterosexual => new SexualOrientation[] { SexualOrientation.Heterosexual }, + SexualOrientation.Heterosexual => [SexualOrientation.Heterosexual], SexualOrientation.Homosexual => [SexualOrientation.Homosexual], _ => [] }; @@ -218,19 +218,19 @@ public static IReadOnlyList GetSexualOrientation(ProfileModel #region BIO - public static IReadOnlyList GetRaceCategory(ProfilePreferenceModel? pref = null) + public static HashSet GetRaceCategory(ProfilePreferenceModel? pref = null) { - if (pref != null && pref.RaceCategory.Any()) return pref.RaceCategory; + if (pref != null && pref.RaceCategory.Count != 0) return pref.RaceCategory; else return []; } - public static IReadOnlyList GetBodyMass(ProfilePreferenceModel? pref = null) + public static HashSet GetBodyMass(ProfilePreferenceModel? pref = null) { - if (pref != null && pref.BodyMass.Any()) return pref.BodyMass; + if (pref != null && pref.BodyMass.Count != 0) return pref.BodyMass; else return []; } - public static IReadOnlyList GetAge(ProfileModel user, ProfilePreferenceModel? pref = null, bool force = false) + public static int[] GetAge(ProfileModel user, ProfilePreferenceModel? pref = null, bool force = false) { int min; int max; @@ -254,11 +254,11 @@ public static IReadOnlyList GetAge(ProfileModel user, ProfilePreferenceMode return [min, max]; } - public static IReadOnlyList GetZodiac(ProfileModel user) + public static HashSet GetZodiac(ProfileModel user) { return user.Zodiac switch { - Zodiac.Aries => new Zodiac[] { Zodiac.Leo, Zodiac.Sagittarius }, + Zodiac.Aries => [Zodiac.Leo, Zodiac.Sagittarius], Zodiac.Taurus => [Zodiac.Virgo, Zodiac.Capricorn], Zodiac.Gemini => [Zodiac.Libra, Zodiac.Aquarius], Zodiac.Cancer => [Zodiac.Scorpio, Zodiac.Pisces], @@ -274,7 +274,7 @@ public static IReadOnlyList GetZodiac(ProfileModel user) }; } - public static IReadOnlyList GetHeight(ProfileModel user, ProfilePreferenceModel? pref = null, bool force = false) + public static Height[] GetHeight(ProfileModel user, ProfilePreferenceModel? pref = null, bool force = false) { Height min; Height max; @@ -290,13 +290,14 @@ public static IReadOnlyList GetHeight(ProfileModel user, ProfilePreferen { int minHeight; - if (pref != null && pref.BiologicalSex.Any() && pref.BiologicalSex.Count == 1) + if (pref != null && pref.BiologicalSex.Count != 0 && pref.BiologicalSex.Count == 1) { - if (user.BiologicalSex == BiologicalSex.Male && pref.BiologicalSex[0] == BiologicalSex.Female) + //TODO: USE CONTAINS? + if (user.BiologicalSex == BiologicalSex.Male && pref.BiologicalSex.First() == BiologicalSex.Female) { minHeight = (int)Math.Round((int)user.Height.Value / (ratio + 0.04)); } - else if (user.BiologicalSex == BiologicalSex.Female && pref.BiologicalSex[0] == BiologicalSex.Male) + else if (user.BiologicalSex == BiologicalSex.Female && pref.BiologicalSex.First() == BiologicalSex.Male) { minHeight = (int)Math.Round((int)user.Height.Value * (ratio - 0.04)); } @@ -329,13 +330,14 @@ public static IReadOnlyList GetHeight(ProfileModel user, ProfilePreferen { int maxHeight; - if (pref != null && pref.BiologicalSex.Any() && pref.BiologicalSex.Count == 1) + if (pref != null && pref.BiologicalSex.Count != 0 && pref.BiologicalSex.Count == 1) { - if (user.BiologicalSex == BiologicalSex.Male && pref.BiologicalSex[0] == BiologicalSex.Female) + //TODO: USE CONTAINS? + if (user.BiologicalSex == BiologicalSex.Male && pref.BiologicalSex.First() == BiologicalSex.Female) { maxHeight = (int)Math.Round((int)user.Height.Value / (ratio - 0.04)); } - else if (user.BiologicalSex == BiologicalSex.Female && pref.BiologicalSex[0] == BiologicalSex.Male) + else if (user.BiologicalSex == BiologicalSex.Female && pref.BiologicalSex.First() == BiologicalSex.Male) { maxHeight = (int)Math.Round((int)user.Height.Value * (ratio + 0.04)); } @@ -361,7 +363,7 @@ public static IReadOnlyList GetHeight(ProfileModel user, ProfilePreferen return [min, max]; } - public static IReadOnlyList GetNeurodiversity(ProfilePreferenceModel? pref = null) + public static HashSet GetNeurodiversity(ProfilePreferenceModel? pref = null) { if (pref != null) return pref.Neurodiversities; @@ -369,7 +371,7 @@ public static IReadOnlyList GetNeurodiversity(ProfilePreferenceM return []; } - public static IReadOnlyList GetDisability(ProfilePreferenceModel? pref = null) + public static HashSet GetDisability(ProfilePreferenceModel? pref = null) { if (pref != null) return pref.Disabilities; @@ -381,9 +383,9 @@ public static IReadOnlyList GetDisability(ProfilePreferenceModel? pr #region LIFESTYLE - public static IReadOnlyList GetDrink(ProfileModel user, ProfilePreferenceModel? pref = null) + public static HashSet GetDrink(ProfileModel user, ProfilePreferenceModel? pref = null) { - if (pref != null && pref.Drink.Any()) + if (pref != null && pref.Drink.Count != 0) { return pref.Drink; } @@ -391,7 +393,7 @@ public static IReadOnlyList GetDrink(ProfileModel user, ProfilePreference { return user.Drink switch { - Drink.No => new Drink[] { Drink.No, Drink.YesLight }, + Drink.No => [Drink.No, Drink.YesLight], Drink.YesLight => [Drink.No, Drink.YesLight, Drink.YesModerate], Drink.YesModerate => [Drink.YesLight, Drink.YesModerate, Drink.YesHeavy], Drink.YesHeavy => [Drink.YesModerate, Drink.YesHeavy], @@ -400,9 +402,9 @@ public static IReadOnlyList GetDrink(ProfileModel user, ProfilePreference } } - public static IReadOnlyList GetSmoke(ProfileModel user, ProfilePreferenceModel? pref = null) + public static HashSet GetSmoke(ProfileModel user, ProfilePreferenceModel? pref = null) { - if (pref != null && pref.Smoke.Any()) + if (pref != null && pref.Smoke.Count != 0) { return pref.Smoke; } @@ -410,7 +412,7 @@ public static IReadOnlyList GetSmoke(ProfileModel user, ProfilePreference { return user.Smoke switch { - Smoke.No => new Smoke[] { Smoke.No }, + Smoke.No => [Smoke.No], Smoke.YesOccasionally => [Smoke.YesOccasionally, Smoke.YesOften], Smoke.YesOften => [Smoke.YesOccasionally, Smoke.YesOften], _ => [] @@ -418,17 +420,17 @@ public static IReadOnlyList GetSmoke(ProfileModel user, ProfilePreference } } - public static IReadOnlyList GetDiet(ProfileModel user, ProfilePreferenceModel? pref = null) + public static HashSet GetDiet(ProfileModel user, ProfilePreferenceModel? pref = null) { - if (pref != null && pref.Diet.Any()) + if (pref != null && pref.Diet.Count != 0) { return pref.Diet; } else { - var group01 = new Diet[] { Diet.Omnivore, Diet.Flexitarian, Diet.GlutenFree }; - var group02 = new Diet[] { Diet.Vegetarian, Diet.Vegan }; - var group03 = new Diet[] { Diet.RawFood, Diet.OrganicAllnaturalLocal }; + var group01 = new HashSet([Diet.Omnivore, Diet.Flexitarian, Diet.GlutenFree]); + var group02 = new HashSet([Diet.Vegetarian, Diet.Vegan]); + var group03 = new HashSet([Diet.RawFood, Diet.OrganicAllnaturalLocal]); return user.Diet switch { @@ -445,21 +447,21 @@ public static IReadOnlyList GetDiet(ProfileModel user, ProfilePreferenceMo } } - public static IReadOnlyList GetReligion(ProfileModel user, ProfilePreferenceModel? pref = null) + public static HashSet GetReligion(ProfileModel user, ProfilePreferenceModel? pref = null) { - if (pref != null && pref.Religion.Any()) + if (pref != null && pref.Religion.Count != 0) { return pref.Religion; } else { - return [user.Religion.Value]; + return [user.Religion ?? throw new NotificationException("Religion null")]; } } - public static IReadOnlyList GetHaveChildren(ProfileModel user, ProfilePreferenceModel? pref = null) + public static HashSet GetHaveChildren(ProfileModel user, ProfilePreferenceModel? pref = null) { - if (pref != null && pref.HaveChildren.Any()) + if (pref != null && pref.HaveChildren.Count != 0) { return pref.HaveChildren; } @@ -467,7 +469,7 @@ public static IReadOnlyList GetHaveChildren(ProfileModel user, Pro { return user.HaveChildren switch { - HaveChildren.No => new HaveChildren[] { HaveChildren.No, HaveChildren.YesNo }, + HaveChildren.No => [HaveChildren.No, HaveChildren.YesNo], HaveChildren.YesNo => [HaveChildren.No, HaveChildren.YesNo], HaveChildren.Yes => [HaveChildren.Yes], _ => [] @@ -475,9 +477,9 @@ public static IReadOnlyList GetHaveChildren(ProfileModel user, Pro } } - public static IReadOnlyList GetWantChildren(ProfileModel user, ProfilePreferenceModel? pref = null) + public static HashSet GetWantChildren(ProfileModel user, ProfilePreferenceModel? pref = null) { - if (pref != null && pref.WantChildren.Any()) + if (pref != null && pref.WantChildren.Count != 0) { return pref.WantChildren; } @@ -485,7 +487,7 @@ public static IReadOnlyList GetWantChildren(ProfileModel user, Pro { return user.WantChildren switch { - WantChildren.No => new WantChildren[] { WantChildren.No }, + WantChildren.No => [WantChildren.No], WantChildren.Maybe => [WantChildren.Maybe, WantChildren.Yes], WantChildren.Yes => [WantChildren.Maybe, WantChildren.Yes], _ => [] @@ -493,33 +495,33 @@ public static IReadOnlyList GetWantChildren(ProfileModel user, Pro } } - public static IReadOnlyList GetEducationLevel(ProfileModel user, ProfilePreferenceModel? pref = null) + public static HashSet GetEducationLevel(ProfileModel user, ProfilePreferenceModel? pref = null) { - if (pref != null && pref.EducationLevel.Any()) + if (pref != null && pref.EducationLevel.Count != 0) { return pref.EducationLevel; } else { - return [user.EducationLevel.Value]; + return [user.EducationLevel ?? throw new NotificationException("EducationLevel null")]; } } - public static IReadOnlyList GetCareerCluster(ProfileModel user, ProfilePreferenceModel? pref = null) + public static HashSet GetCareerCluster(ProfileModel user, ProfilePreferenceModel? pref = null) { - if (pref != null && pref.CareerCluster.Any()) + if (pref != null && pref.CareerCluster.Count != 0) { return pref.CareerCluster; } else { - return [user.CareerCluster.Value]; + return [user.CareerCluster ?? throw new NotificationException("CareerCluster null")]; } } - public static IReadOnlyList GetTravelFrequency(ProfileModel user, ProfilePreferenceModel? pref = null) + public static HashSet GetTravelFrequency(ProfileModel user, ProfilePreferenceModel? pref = null) { - if (pref != null && pref.TravelFrequency.Any()) + if (pref != null && pref.TravelFrequency.Count != 0) { return pref.TravelFrequency; } @@ -527,7 +529,7 @@ public static IReadOnlyList GetTravelFrequency(ProfileModel use { return user.TravelFrequency switch { - TravelFrequency.NeverRarely => new TravelFrequency[] { TravelFrequency.NeverRarely, TravelFrequency.SometimesFrequently }, + TravelFrequency.NeverRarely => [TravelFrequency.NeverRarely, TravelFrequency.SometimesFrequently], TravelFrequency.SometimesFrequently => [TravelFrequency.NeverRarely, TravelFrequency.SometimesFrequently, TravelFrequency.UsuallyAlwaysNomad], TravelFrequency.UsuallyAlwaysNomad => [TravelFrequency.SometimesFrequently, TravelFrequency.UsuallyAlwaysNomad], _ => [] @@ -539,12 +541,12 @@ public static IReadOnlyList GetTravelFrequency(ProfileModel use #region PERSONALITY - public static IReadOnlyList GetMoneyPersonality(ProfileModel user) + public static HashSet GetMoneyPersonality(ProfileModel user) { return user.MoneyPersonality.ToArray(); } - public static IReadOnlyList GetSharedSpendingStyle(ProfileModel user) + public static HashSet GetSharedSpendingStyle(ProfileModel user) { //invented by me (dhiogo) @@ -559,7 +561,7 @@ public static IReadOnlyList GetSharedSpendingStyle(ProfileM }; } - public static IReadOnlyList GetRelationshipPersonality(ProfileModel user) + public static HashSet GetRelationshipPersonality(ProfileModel user) { //https://helenfisher.com/downloads/articles/Article_%20We%20Have%20Chemistry.pdf @@ -573,7 +575,7 @@ public static IReadOnlyList GetRelationshipPersonality( }; } - public static IReadOnlyList GetMyersBriggsTypeIndicator(ProfileModel user) + public static HashSet GetMyersBriggsTypeIndicator(ProfileModel user) { //http://www.personalityrelationships.net/ //https://web.archive.org/web/20220322143220/http://www.personalityrelationships.net/ @@ -581,7 +583,7 @@ public static IReadOnlyList GetMyersBriggsTypeIndicato return user.MBTI switch { - MyersBriggsTypeIndicator.INTJ => new MyersBriggsTypeIndicator[] { MyersBriggsTypeIndicator.ENTP, MyersBriggsTypeIndicator.ENFP }, + MyersBriggsTypeIndicator.INTJ => [MyersBriggsTypeIndicator.ENTP, MyersBriggsTypeIndicator.ENFP], MyersBriggsTypeIndicator.INTP => [MyersBriggsTypeIndicator.ENTJ, MyersBriggsTypeIndicator.ENFJ], MyersBriggsTypeIndicator.ENTJ => [MyersBriggsTypeIndicator.INTP, MyersBriggsTypeIndicator.INFP], MyersBriggsTypeIndicator.ENTP => [MyersBriggsTypeIndicator.INTJ, MyersBriggsTypeIndicator.INFJ], @@ -604,16 +606,16 @@ public static IReadOnlyList GetMyersBriggsTypeIndicato }; } - public static IReadOnlyList GetLoveLanguage(ProfileModel user) + public static HashSet GetLoveLanguage(ProfileModel user) { return user.LoveLanguage.ToArray(); } - public static IReadOnlyList GetSexPersonality(ProfileModel user, ProfilePreferenceModel? pref = null) + public static HashSet GetSexPersonality(ProfileModel user) { - if (pref != null && pref.SexPersonality.Any()) + if (user.SexPersonalityPreference.Count != 0) { - return pref.SexPersonality; + return user.SexPersonalityPreference; } else { @@ -625,44 +627,44 @@ public static IReadOnlyList GetSexPersonality(ProfileModel user, #region INTEREST - public static IReadOnlyList GetFood(ProfileModel user) + public static HashSet GetFood(ProfileModel user) { - return user.Food.ToArray(); + return user.Food; } - public static IReadOnlyList GetVacation(ProfileModel user) + public static HashSet GetVacation(ProfileModel user) { - return user.Vacation.ToArray(); + return user.Vacation; } - public static IReadOnlyList GetSports(ProfileModel user) + public static HashSet GetSports(ProfileModel user) { - return user.Sports.ToArray(); + return user.Sports; } - public static IReadOnlyList GetLeisureActivities(ProfileModel user) + public static HashSet GetLeisureActivities(ProfileModel user) { - return user.LeisureActivities.ToArray(); + return user.LeisureActivities; } - public static IReadOnlyList GetMusicGenre(ProfileModel user) + public static HashSet GetMusicGenre(ProfileModel user) { - return user.MusicGenre.ToArray(); + return user.MusicGenre; } - public static IReadOnlyList GetMovieGenre(ProfileModel user) + public static HashSet GetMovieGenre(ProfileModel user) { - return user.MovieGenre.ToArray(); + return user.MovieGenre; } - public static IReadOnlyList GetTVGenre(ProfileModel user) + public static HashSet GetTVGenre(ProfileModel user) { - return user.TVGenre.ToArray(); + return user.TVGenre; } - public static IReadOnlyList GetReadingGenre(ProfileModel user) + public static HashSet GetReadingGenre(ProfileModel user) { - return user.ReadingGenre.ToArray(); + return user.ReadingGenre; } #endregion INTEREST @@ -688,12 +690,12 @@ public static int GetPercentAffinity(this List Affinities, Section? } else { - double totCheck = Affinities.Count(w => w.Section == category && w.HaveAffinity); - double totItens = Affinities.Count(w => w.Section == category); + var totCheck = Affinities.Count(w => w.Section == category && w.HaveAffinity); + var totItens = Affinities.Count(w => w.Section == category); if (totCheck == 0 || totItens == 0) return 0; - return Convert.ToInt32(Math.Round(totCheck / totItens * 100, 0)); + return Convert.ToInt32(Math.Round((double)totCheck / totItens * 100, 0)); } } } diff --git a/MM.WEB/Core/Api/ApiCosmos.cs b/MM.WEB/Core/Api/ApiCosmos.cs index 43eb402..393202d 100644 --- a/MM.WEB/Core/Api/ApiCosmos.cs +++ b/MM.WEB/Core/Api/ApiCosmos.cs @@ -11,7 +11,7 @@ public abstract class ApiCosmos(IHttpClientFactory factory, IMemoryCache memo protected IMemoryCache _cache { get; set; } = memoryCache; protected object? cacheKey { get; set; } = cacheKey; - private string baseEndpoint => _http.BaseAddress?.ToString().Contains("localhost") ?? true ? "http://localhost:7071/api/" : $"{_http.BaseAddress}api/"; + private string baseEndpoint => _http.BaseAddress?.ToString().Contains("localhost") ?? true ? "http://localhost:7091/api/" : $"{_http.BaseAddress}api/"; protected void CleanCache() { diff --git a/MM.WEB/Core/Api/CacheSettings.cs b/MM.WEB/Core/Api/CacheSettings.cs index 1457f65..1016427 100644 --- a/MM.WEB/Core/Api/CacheSettings.cs +++ b/MM.WEB/Core/Api/CacheSettings.cs @@ -10,4 +10,4 @@ public CacheSettings(TimeSpan? SlidingExpiration = null, TimeSpan? AbsoluteExpir this.AbsoluteExpirationRelativeToNow = AbsoluteExpirationRelativeToNow ?? TimeSpan.FromMinutes(10); } } -} +} \ No newline at end of file diff --git a/MM.WEB/Core/AppStateStatic.cs b/MM.WEB/Core/AppStateStatic.cs index 2b486ea..4f766e2 100644 --- a/MM.WEB/Core/AppStateStatic.cs +++ b/MM.WEB/Core/AppStateStatic.cs @@ -9,6 +9,7 @@ public static class AppStateStatic public static List Logs { get; private set; } = []; public static Language Language { get; private set; } + public static Bar? Sidebar { get; set; } public static Action? RegistrationSuccessful { get; set; } @@ -25,14 +26,14 @@ static AppStateStatic() { Enum.TryParse(typeof(Language), CultureInfo.CurrentCulture.Name.Replace("-", ""), out object? language); - Language = (Language?)language ?? Language.en; + Language = (Language?)language ?? Language.English; } public static string GetLanguageCode() { switch (Language) { - case Language.pt: return "pt"; + case Language.Portuguese: return "pt"; default: return "en"; } } diff --git a/MM.WEB/Core/PopupHelper.cs b/MM.WEB/Core/PopupHelper.cs index 0fba920..2752f06 100644 --- a/MM.WEB/Core/PopupHelper.cs +++ b/MM.WEB/Core/PopupHelper.cs @@ -4,6 +4,7 @@ using MM.Shared.Models.Support; using MM.WEB.Modules.Subscription.Components; using MM.WEB.Modules.Support.Component; +using MM.WEB.Shared; namespace MM.WEB.Core { @@ -11,7 +12,8 @@ public static class PopupHelper { public static readonly EventCallbackFactory Factory = new(); - //public static async Task CollectionPopup(this IModalService service, WatchedList? watched, WatchingList? watching, WishList? wish, MediaType? type, string? collection_id, bool showPrivateAction) + //public static async Task CollectionPopup(this IModalService service, WatchedList? watched, WatchingList? watching, WishList? wish, MediaType? type, + // string? collection_id, bool showPrivateAction, bool IsAuthenticated) //{ // await service.Show(null, x => // { @@ -24,10 +26,12 @@ public static class PopupHelper // x.Add(x => x.WatchingChanged, Factory.Create(new(), (WatchingList? list) => { watching = list; })); // x.Add(x => x.WishChanged, Factory.Create(new(), (WishList? list) => { wish = list; })); // x.Add(x => x.ShowPrivateAction, showPrivateAction); + // x.Add(x => x.IsAuthenticated, IsAuthenticated); // }, Options(ModalSize.Large)); //} - //public static async Task CompleteListPopup(this IModalService service, string? TitleHead, WatchedList? watched, WatchingList? watching, WishList? wish, HashSet Items, bool showPrivateAction) + //public static async Task CompleteListPopup(this IModalService service, string? TitleHead, WatchedList? watched, WatchingList? watching, WishList? wish, + // HashSet Items, bool showPrivateAction, bool IsAuthenticated) //{ // await service.Show(null, x => // { @@ -40,11 +44,13 @@ public static class PopupHelper // x.Add(x => x.WishChanged, Factory.Create(new(), (WishList? list) => { wish = list; })); // x.Add(x => x.Items, Items); // x.Add(x => x.ShowPrivateAction, showPrivateAction); + // x.Add(x => x.IsAuthenticated, IsAuthenticated); // }, Options(ModalSize.ExtraLarge)); //} //public static async Task CompleteListPopup(this IModalService service, string? TitleHead, WatchedList? watched, WatchingList? watching, WishList? wish, HashSet Items, - // IMediaListApi? MediaListApi, EnumLists? List, int MaxItens, bool IsIMDB, MediaType? TypeSelected, Dictionary StringParameters, bool showPrivateAction) + // IMediaListApi? MediaListApi, EnumLists? List, int MaxItens, bool IsIMDB, MediaType? TypeSelected, Dictionary StringParameters, + // bool showPrivateAction, bool IsAuthenticated) //{ // await service.Show(null, x => // { @@ -64,10 +70,12 @@ public static class PopupHelper // x.Add(x => x.TypeSelected, TypeSelected); // x.Add(x => x.StringParameters, StringParameters); // x.Add(x => x.ShowPrivateAction, showPrivateAction); + // x.Add(x => x.IsAuthenticated, IsAuthenticated); // }, Options(ModalSize.ExtraLarge)); //} - //public static async Task CompleteListProvider(this IModalService service, string? cardHeader, AllProviders? allProviders, WatchedList? watched, WatchingList? watching, WishList? wish, bool showPrivateAction) + //public static async Task CompleteListProvider(this IModalService service, string? cardHeader, AllProviders? allProviders, WatchedList? watched, + // WatchingList? watching, WishList? wish, bool showPrivateAction, bool IsAuthenticated) //{ // await service.Show(null, x => // { @@ -77,10 +85,12 @@ public static class PopupHelper // x.Add(x => x.Watching, watching); // x.Add(x => x.Wish, wish); // x.Add(x => x.ShowPrivateAction, showPrivateAction); + // x.Add(x => x.IsAuthenticated, IsAuthenticated); // }, Options(ModalSize.ExtraLarge)); //} - //public static async Task MediaPopup(this IModalService service, WatchedList? watched, WatchingList? watching, WishList? wish, MediaType? type, string? tmdb_id, bool showPrivateAction) + //public static async Task MediaPopup(this IModalService service, WatchedList? watched, WatchingList? watching, WishList? wish, MediaType? type, string? tmdb_id, + // bool showPrivateAction, bool IsAuthenticated) //{ // await service.Show(null, x => // { @@ -93,11 +103,12 @@ public static class PopupHelper // x.Add(x => x.WatchingChanged, Factory.Create(new(), (WatchingList? list) => { watching = list; })); // x.Add(x => x.WishChanged, Factory.Create(new(), (WishList? list) => { wish = list; })); // x.Add(x => x.ShowPrivateAction, showPrivateAction); + // x.Add(x => x.IsAuthenticated, IsAuthenticated); // }, Options(ModalSize.Large)); //} - //public static async Task MySuggestionsPopup(this IModalService service, MM.Shared.Models.MySuggestions? MySuggestions, - // EventCallback? MySuggestionsChanged) + //public static async Task MySuggestionsPopup(this IModalService service, SD.Shared.Models.MySuggestions? MySuggestions, + // EventCallback? MySuggestionsChanged) //{ // await service.Show(null, x => // { @@ -106,8 +117,17 @@ public static class PopupHelper // }, Options(ModalSize.Default)); //} + public static async Task SettingsPopup(this IModalService service) + { + await service.Show(null, x => + { + //x.Add(x => x.MySuggestions, MySuggestions); + //x.Add(x => x.MySuggestionsChanged, MySuggestionsChanged); + }, Options(ModalSize.Default)); + } + //public static async Task MyWatchingListPopup(this IModalService service, RenderControlCore? Core, MediaType MediaType, - // WatchedList? watched, WatchingList? watching, WishList? wish, bool showPrivateAction) + // WatchedList? watched, WatchingList? watching, WishList? wish, bool showPrivateAction, bool IsAuthenticated, string? UserId) //{ // await service.Show(null, x => // { @@ -120,11 +140,13 @@ public static class PopupHelper // x.Add(x => x.WatchingChanged, Factory.Create(new(), (WatchingList? list) => { watching = list; })); // x.Add(x => x.WishChanged, Factory.Create(new(), (WishList? list) => { wish = list; })); // x.Add(x => x.ShowPrivateAction, showPrivateAction); + // x.Add(x => x.IsAuthenticated, IsAuthenticated); + // x.Add(x => x.UserId, UserId); // }, Options(ModalSize.ExtraLarge)); //} //public static async Task MyWishListPopup(this IModalService service, RenderControlCore? Core, - // WatchedList? watched, WatchingList? watching, WishList? wish, MediaType type, bool showPrivateAction) + // WatchedList? watched, WatchingList? watching, WishList? wish, MediaType type, bool showPrivateAction, bool IsAuthenticated, string? UserId) //{ // await service.Show(null, x => // { @@ -137,6 +159,8 @@ public static class PopupHelper // x.Add(x => x.WatchingChanged, Factory.Create(new(), (WatchingList? list) => { watching = list; })); // x.Add(x => x.WishChanged, Factory.Create(new(), (WishList? list) => { wish = list; })); // x.Add(x => x.ShowPrivateAction, showPrivateAction); + // x.Add(x => x.IsAuthenticated, IsAuthenticated); + // x.Add(x => x.UserId, UserId); // }, Options(ModalSize.ExtraLarge)); //} @@ -156,7 +180,8 @@ await service.Show(null, x => }, Options(ModalSize.Default)); } - //public static async Task ProviderPopup(this IModalService service, ProviderModel? provider, WatchedList? watched, WatchingList? watching, WishList? wish, bool showPrivateAction) + //public static async Task ProviderPopup(this IModalService service, ProviderModel? provider, WatchedList? watched, WatchingList? watching, WishList? wish, + // bool showPrivateAction, string? WatchRegion, string? ProviderId, bool IsAuthenticated) //{ // await service.Show(null, x => // { @@ -168,10 +193,14 @@ await service.Show(null, x => // x.Add(x => x.WatchingChanged, Factory.Create(new(), (WatchingList? list) => { watching = list; })); // x.Add(x => x.WishChanged, Factory.Create(new(), (WishList? list) => { wish = list; })); // x.Add(x => x.ShowPrivateAction, showPrivateAction); + // x.Add(x => x.WatchRegion, WatchRegion); + // x.Add(x => x.ProviderId, ProviderId); + // x.Add(x => x.IsAuthenticated, IsAuthenticated); // }, Options(ModalSize.ExtraLarge)); //} - //public static async Task SearchPopup(this IModalService service, string? titleHead, string? search, WatchedList? watched, WatchingList? watching, WishList? wish, bool showPrivateAction) + //public static async Task SearchPopup(this IModalService service, string? titleHead, string? search, WatchedList? watched, WatchingList? watching, WishList? wish, + // bool showPrivateAction, bool IsAuthenticated) //{ // await service.Show(null, x => // { @@ -184,6 +213,7 @@ await service.Show(null, x => // x.Add(x => x.WatchingChanged, Factory.Create(new(), (WatchingList? list) => { watching = list; })); // x.Add(x => x.WishChanged, Factory.Create(new(), (WishList? list) => { wish = list; })); // x.Add(x => x.ShowPrivateAction, showPrivateAction); + // x.Add(x => x.IsAuthenticated, IsAuthenticated); // }, Options(ModalSize.ExtraLarge)); //} @@ -213,6 +243,7 @@ public static async Task SubscriptionPopup(this IModalService service, ClientePr await service.Show(null, x => { x.Add(x => x.Client, client); + x.Add(x => x.IsAuthenticated, IsAuthenticated); }, Options(ModalSize.Large)); } diff --git a/MM.WEB/MM.WEB.csproj b/MM.WEB/MM.WEB.csproj index 521f988..02d3610 100644 --- a/MM.WEB/MM.WEB.csproj +++ b/MM.WEB/MM.WEB.csproj @@ -13,7 +13,6 @@ - @@ -24,24 +23,24 @@ - - - - - - - + + + + + + + - - + + true - - + + true - + @@ -151,8 +150,6 @@ Static true $([System.DateTime]::Now.ToString(yyyy.MM.dd)) - - 16777216 diff --git a/MM.WEB/Modules/Administrator/Index.razor b/MM.WEB/Modules/Administrator/Index.razor index ea44498..3b6cccd 100644 --- a/MM.WEB/Modules/Administrator/Index.razor +++ b/MM.WEB/Modules/Administrator/Index.razor @@ -26,9 +26,6 @@ - - - diff --git a/MM.WEB/Modules/Auth/ProfilePrincipal.razor b/MM.WEB/Modules/Auth/ProfilePrincipal.razor index 9b8a991..6547193 100644 --- a/MM.WEB/Modules/Auth/ProfilePrincipal.razor +++ b/MM.WEB/Modules/Auth/ProfilePrincipal.razor @@ -49,7 +49,7 @@ - @if (AppStateStatic.Language == Language.pt) + @if (AppStateStatic.Language == Language.Portuguese) { Aceito os Termos de Uso } diff --git a/MM.WEB/Modules/Index.razor b/MM.WEB/Modules/Index.razor index 0f3bad0..002983f 100644 --- a/MM.WEB/Modules/Index.razor +++ b/MM.WEB/Modules/Index.razor @@ -1,307 +1,73 @@ @page "/" -@page "/Index" -@using MM.Shared.Models.Profile; -@using MM.WEB.Modules.Profile.Core; -@attribute [Authorize] -@inherits PageCore +@page "/index" -@inject ProfileApi ProfileApi +@inject IJSRuntime JsRuntime - - - Seu Perfil (@profile?.NickName) - - @foreach (var item in imageDataUriGallery) + + + + @foreach (var item in Highlights) + { + + + } + + + + + + @foreach (var item in Suggestions) + { + + + } + + + + + + + + @foreach (var item in Likes) { - - - + + } - - - - - - - - - - - - - - - - - - @if (profile?.Modality == Modality.Matchmaker) - { - @* - - @string.Format(Resources.CardHeader.IndexHighlights, GetSuggestionTitle()) - - - - - @foreach (var item in lstDestaques) + + + + + @foreach (var item in Matches) { - - - @* - - *@@* - @item.NickName, @item.Age - @if (item.ActivityStatus == ActivityStatus.Today) - { - - - - } - else if (item.ActivityStatus == ActivityStatus.Week) - { - - - - } - else if (item.ActivityStatus == ActivityStatus.Month) - { - - - - } - else - { - - - - } - - - - - - - - } - - - - - - @Resources.CardHeader.ProfileIndexInteractions - - - - - - - - - - - - - - - - - - - - *@ + + } - else if (profile?.Modality == Modality.RelationshipAnalysis) - { - Seu Parceiro (@(view?.NickName ?? "...")) - - - - - - - @if (view != null) - { - - @foreach (var item in imageDataUriGallery) - { - - - - } - - } - - - @if (view != null) - { - @* - @view.NickName - *@ - @* - @view?.GetLocation(ProfileModel.LocationType.City) - *@ - @* @if (view.ActivityStatus == ActivityStatus.Today) - { - - logado hoje - - } - else if (view.ActivityStatus == ActivityStatus.Week) - { - - logado esta semana - - } - else if (view.ActivityStatus == ActivityStatus.Month) - { - - logado este mês - - } - else - { - - usuário desativado - - } *@ - @* @if (view.Reports.Any()) - { - - @foreach (var item in view?.Reports ?? Array.Empty()) - { - - @item.Type.GetName() - - } - - }*@ - } - - - - - - - - - } - + -@code -{ - private ProfileModel? profile; - public RenderControlCore? Core { get; set; } = new(); - - private ProfileModel? view; - private List affinities = new(); - //private List lstDestaques = new(); +@code { + [Parameter][SupplyParameterFromQuery(Name = "language")] public string? language { get; set; } + [Parameter][SupplyParameterFromQuery(Name = "platform")] public string? platform { get; set; } - string? selectedImage; - string[] imageDataUriGallery = new string[] { }; + public List Highlights { get; set; } = []; + public List Suggestions { get; set; } = []; + public List Likes { get; set; } = []; + public List Matches { get; set; } = []; - //private bool ProfileLoading = true; - //private bool ViewLoading = true; - private bool SuggestionsLoading = true; - - // public Loading ProfileLoading { get; set; } = default!; - // public Loading ViewLoading { get; set; } = default!; - - protected override async Task LoadDataRender() + protected override async Task OnInitializedAsync() { - try - { - if (IsAuthenticated) - { - // ProfileLoading.Start(); - profile = await ProfileApi.Get(Core); - // ProfileLoading.Finish(profile == null, "Perfil não encontrado. Favor, realizar seu cadastro para poder usar todas as funcionalidades"); - // ProfileLoading.Finish(profile?.Preference == null, "Preferências não encontradas. Favor, realizar seu preenchimento para poder usar todas as funcionalidades"); - - if (profile != null) - { - if (profile.Modality == Modality.RelationshipAnalysis) - { - // ViewLoading.Start(); - var partner = profile.Partners.FirstOrDefault(w => !string.IsNullOrEmpty(w.Id)); - // view = await ProfileApi.Profile_GetView(partner?.Id); - // ViewLoading.Finish(view == null); - } - else - { - SuggestionsLoading = true; - //lstDestaques = await Http.Public_ListDestaques(SessionStorage); - //lstDestaques = await Http.Profile_ListSearch(SessionStorage); - SuggestionsLoading = false; - } + await base.OnInitializedAsync(); - imageDataUriGallery = new string[] { profile.GetMainPhoto() }.Concat(profile.GetGalleryPhotos()).ToArray(); - - if (view != null) - { - affinities = AffinityCore.GetAffinity(profile, view); - } - } - else - { - imageDataUriGallery = new string[] { ImageHelper.GetNoUserPhoto }; - } - - selectedImage = imageDataUriGallery.First(); - - //ProfileLoading = false; - //ViewLoading = false; - SuggestionsLoading = false; - } - } - catch (Exception ex) + if (platform.NotEmpty()) { - ex.ProcessException(Toast, Logger); + await JsRuntime.InvokeAsync("SetLocalStorage", "platform", platform); } - } - - private string GetSuggestionTitle() - { - if (profile?.Preference?.Region == null) return ""; - - switch (profile.Preference.Region) + else { - case Region.City: - return $"{profile.Preference.Region.GetName()} - {profile?.GetLocation(ProfileModel.LocationType.City)}"; - case Region.State: - return $"{profile.Preference.Region.GetName()} - {profile?.GetLocation(ProfileModel.LocationType.State)}"; - case Region.Country: - return $"{profile.Preference.Region.GetName()} - {profile?.GetLocation(ProfileModel.LocationType.Country)}"; - case Region.World: - return $"{profile.Preference.Region.GetName()}"; - default: - return ""; + await JsRuntime.InvokeAsync("TryDetectPlatform"); } } -} \ No newline at end of file +} diff --git a/MM.WEB/Modules/Profile/Components/CardCompatibility.razor b/MM.WEB/Modules/Profile/Components/CardCompatibility.razor index b11f575..538591e 100644 --- a/MM.WEB/Modules/Profile/Components/CardCompatibility.razor +++ b/MM.WEB/Modules/Profile/Components/CardCompatibility.razor @@ -56,15 +56,15 @@ @if (View != null && User?.Preference != null) { - - - - - - - - - + + + + + + + + + } @@ -77,7 +77,7 @@ - + } diff --git a/MM.WEB/Modules/Profile/Components/ItemDataProfile.razor b/MM.WEB/Modules/Profile/Components/ItemDataProfile.razor index 9a3a2a2..8210c52 100644 --- a/MM.WEB/Modules/Profile/Components/ItemDataProfile.razor +++ b/MM.WEB/Modules/Profile/Components/ItemDataProfile.razor @@ -23,11 +23,11 @@ else @code { [Parameter] public Expression>? For { get; set; } [Parameter] public TValue? Value { get; set; } - [Parameter] public IReadOnlyList? Values { get; set; } + [Parameter] public IEnumerable? Values { get; set; } [Parameter] public TValueUser? ValueUser { get; set; } - [Parameter] public IReadOnlyList? ValuesUser { get; set; } + [Parameter] public IEnumerable? ValuesUser { get; set; } [Parameter] public string? ClassIcon { get; set; } - [Parameter] public List Affinities { get; set; } = new(); + [Parameter] public List Affinities { get; set; } = []; [Parameter] public CompatibilityType Type { get; set; } [Parameter] public CompatibilityItem Item { get; set; } @@ -142,56 +142,56 @@ else return result; } - private List GetExpectedValue() + private IEnumerable GetExpectedValue() { - if (User == null) return new(); + if (User == null) return []; - if (!GetPreferenceValues().Any()) return new(); + if (!GetPreferenceValues().Any()) return []; return Item switch { //BASIC - CompatibilityItem.Location => AffinityCore.GetLocation(User).ToArray().ToList(), - CompatibilityItem.Language => AffinityCore.GetLanguages(User, User.Preference).Select(s => s.GetName()).ToList(), - CompatibilityItem.CurrentSituation => AffinityCore.GetCurrentSituation(User, User.Preference).Select(s => s.GetName()).ToList(), - CompatibilityItem.Intentions => AffinityCore.GetIntentions(User).Select(s => s.GetName()).ToList(), - CompatibilityItem.BiologicalSex => AffinityCore.GetBiologicalSex(User, User.Preference).Select(s => s.GetName()).ToList(), - CompatibilityItem.GenderIdentity => AffinityCore.GetGenderIdentity(User, User.Preference).Select(s => s.GetName()).ToList(), - CompatibilityItem.SexualOrientation => AffinityCore.GetSexualOrientation(User, User.Preference).Select(s => s.GetName()).ToList(), + CompatibilityItem.Location => AffinityCore.GetLocation(User).ToArray(), + CompatibilityItem.Language => AffinityCore.GetLanguages(User, User.Preference).Select(s => s.GetName()), + CompatibilityItem.CurrentSituation => AffinityCore.GetCurrentSituation(User, User.Preference).Select(s => s.GetName()), + CompatibilityItem.Intentions => AffinityCore.GetIntentions(User).Select(s => s.GetName()), + CompatibilityItem.BiologicalSex => AffinityCore.GetBiologicalSex(User, User.Preference).Select(s => s.GetName()), + CompatibilityItem.GenderIdentity => AffinityCore.GetGenderIdentity(User, User.Preference).Select(s => s.GetName()), + CompatibilityItem.SexualOrientation => AffinityCore.GetSexualOrientation(User, User.Preference).Select(s => s.GetName()), //BIO - CompatibilityItem.RaceCategory => AffinityCore.GetRaceCategory(User.Preference).Select(s => s.GetName()).ToList(), - CompatibilityItem.BodyMass => AffinityCore.GetBodyMass(User.Preference).Select(s => s.GetName()).ToList(), - CompatibilityItem.Age => AffinityCore.GetAge(User, User.Preference).Select(s => s.ToString()).ToList(), - CompatibilityItem.Zodiac => AffinityCore.GetZodiac(User).Select(s => s.GetName()).ToList(), - CompatibilityItem.Height => AffinityCore.GetHeight(User, User.Preference).Select(s => s.GetName()).ToList(), - CompatibilityItem.Neurodiversity => AffinityCore.GetNeurodiversity(User.Preference).Select(s => s.GetName()).ToList(), - CompatibilityItem.Disabilities => AffinityCore.GetDisability(User.Preference).Select(s => s.GetName()).ToList(), + CompatibilityItem.RaceCategory => AffinityCore.GetRaceCategory(User.Preference).Select(s => s.GetName()), + CompatibilityItem.BodyMass => AffinityCore.GetBodyMass(User.Preference).Select(s => s.GetName()), + CompatibilityItem.Age => AffinityCore.GetAge(User, User.Preference).Select(s => s.ToString()), + CompatibilityItem.Zodiac => AffinityCore.GetZodiac(User).Select(s => s.GetName()), + CompatibilityItem.Height => AffinityCore.GetHeight(User, User.Preference).Select(s => s.GetName()), + CompatibilityItem.Neurodiversity => AffinityCore.GetNeurodiversity(User.Preference).Select(s => s.GetName()), + CompatibilityItem.Disabilities => AffinityCore.GetDisability(User.Preference).Select(s => s.GetName()), //LIFESTYLE - CompatibilityItem.Drink => AffinityCore.GetDrink(User, User.Preference).Select(s => s.GetName()).ToList(), - CompatibilityItem.Smoke => AffinityCore.GetSmoke(User, User.Preference).Select(s => s.GetName()).ToList(), - CompatibilityItem.Diet => AffinityCore.GetDiet(User, User.Preference).Select(s => s.GetName()).ToList(), - CompatibilityItem.Religion => AffinityCore.GetReligion(User, User.Preference).Select(s => s.GetName()).ToList(), - CompatibilityItem.HaveChildren => AffinityCore.GetHaveChildren(User, User.Preference).Select(s => s.GetName()).ToList(), - CompatibilityItem.WantChildren => AffinityCore.GetWantChildren(User, User.Preference).Select(s => s.GetName()).ToList(), - CompatibilityItem.EducationLevel => AffinityCore.GetEducationLevel(User, User.Preference).Select(s => s.GetName()).ToList(), - CompatibilityItem.CareerCluster => AffinityCore.GetCareerCluster(User, User.Preference).Select(s => s.GetName()).ToList(), - CompatibilityItem.TravelFrequency => AffinityCore.GetTravelFrequency(User, User.Preference).Select(s => s.GetName()).ToList(), + CompatibilityItem.Drink => AffinityCore.GetDrink(User, User.Preference).Select(s => s.GetName()), + CompatibilityItem.Smoke => AffinityCore.GetSmoke(User, User.Preference).Select(s => s.GetName()), + CompatibilityItem.Diet => AffinityCore.GetDiet(User, User.Preference).Select(s => s.GetName()), + CompatibilityItem.Religion => AffinityCore.GetReligion(User, User.Preference).Select(s => s.GetName()), + CompatibilityItem.HaveChildren => AffinityCore.GetHaveChildren(User, User.Preference).Select(s => s.GetName()), + CompatibilityItem.WantChildren => AffinityCore.GetWantChildren(User, User.Preference).Select(s => s.GetName()), + CompatibilityItem.EducationLevel => AffinityCore.GetEducationLevel(User, User.Preference).Select(s => s.GetName()), + CompatibilityItem.CareerCluster => AffinityCore.GetCareerCluster(User, User.Preference).Select(s => s.GetName()), + CompatibilityItem.TravelFrequency => AffinityCore.GetTravelFrequency(User, User.Preference).Select(s => s.GetName()), //PERSONALITY - CompatibilityItem.MoneyPersonality => AffinityCore.GetMoneyPersonality(User).Select(s => s.GetName()).ToList(), - CompatibilityItem.SharedSpendingStyle => AffinityCore.GetSharedSpendingStyle(User).Select(s => s.GetName()).ToList(), - CompatibilityItem.RelationshipPersonality => AffinityCore.GetRelationshipPersonality(User).Select(s => s.GetName()).ToList(), - CompatibilityItem.MyersBriggsTypeIndicator => AffinityCore.GetMyersBriggsTypeIndicator(User).Select(s => s.GetName()).ToList(), - CompatibilityItem.LoveLanguage => AffinityCore.GetLoveLanguage(User).Select(s => s.GetName()).ToList(), - CompatibilityItem.SexPersonality => AffinityCore.GetSexPersonality(User, Pref).Select(s => s.GetName()).ToList(), + CompatibilityItem.MoneyPersonality => AffinityCore.GetMoneyPersonality(User).Select(s => s.GetName()), + CompatibilityItem.SharedSpendingStyle => AffinityCore.GetSharedSpendingStyle(User).Select(s => s.GetName()), + CompatibilityItem.RelationshipPersonality => AffinityCore.GetRelationshipPersonality(User).Select(s => s.GetName()), + CompatibilityItem.MyersBriggsTypeIndicator => AffinityCore.GetMyersBriggsTypeIndicator(User).Select(s => s.GetName()), + CompatibilityItem.LoveLanguage => AffinityCore.GetLoveLanguage(User).Select(s => s.GetName()), + CompatibilityItem.SexPersonality => AffinityCore.GetSexPersonality(User).Select(s => s.GetName()), //INTEREST - CompatibilityItem.Food => AffinityCore.GetFood(User).Select(s => s.GetName()).ToList(), - CompatibilityItem.Vacation => AffinityCore.GetVacation(User).Select(s => s.GetName()).ToList(), - CompatibilityItem.Sports => AffinityCore.GetSports(User).Select(s => s.GetName()).ToList(), - CompatibilityItem.LeisureActivities => AffinityCore.GetLeisureActivities(User).Select(s => s.GetName()).ToList(), - CompatibilityItem.MusicGenre => AffinityCore.GetMusicGenre(User).Select(s => s.GetName()).ToList(), - CompatibilityItem.MovieGenre => AffinityCore.GetMovieGenre(User).Select(s => s.GetName()).ToList(), - CompatibilityItem.TVGenre => AffinityCore.GetTVGenre(User).Select(s => s.GetName()).ToList(), - CompatibilityItem.ReadingGenre => AffinityCore.GetReadingGenre(User).Select(s => s.GetName()).ToList(), + CompatibilityItem.Food => AffinityCore.GetFood(User).Select(s => s.GetName()), + CompatibilityItem.Vacation => AffinityCore.GetVacation(User).Select(s => s.GetName()), + CompatibilityItem.Sports => AffinityCore.GetSports(User).Select(s => s.GetName()), + CompatibilityItem.LeisureActivities => AffinityCore.GetLeisureActivities(User).Select(s => s.GetName()), + CompatibilityItem.MusicGenre => AffinityCore.GetMusicGenre(User).Select(s => s.GetName()), + CompatibilityItem.MovieGenre => AffinityCore.GetMovieGenre(User).Select(s => s.GetName()), + CompatibilityItem.TVGenre => AffinityCore.GetTVGenre(User).Select(s => s.GetName()), + CompatibilityItem.ReadingGenre => AffinityCore.GetReadingGenre(User).Select(s => s.GetName()), _ => throw new InvalidOperationException("invalid CompatibilityItem: " + Item) }; } diff --git a/MM.WEB/Modules/Profile/Components/MyRelationships.razor b/MM.WEB/Modules/Profile/Components/MyRelationships.razor index f11b6a4..16888f5 100644 --- a/MM.WEB/Modules/Profile/Components/MyRelationships.razor +++ b/MM.WEB/Modules/Profile/Components/MyRelationships.razor @@ -1,7 +1,8 @@ @using FluentValidation; @using MM.Shared.Models.Profile; +@using MM.Shared.Models.Profile.Core @using MM.WEB.Modules.Profile.Core; -@using VerusDate.Web.Api; +@using MM.WEB.Api; @inherits ComponentCore @inject InviteApi InviteApi @@ -10,39 +11,39 @@ - @Resources.CardHeader.MyConnections + @WEB.Resources.CardHeader.MyConnections - + @foreach (var item in profile?.Partners ?? new()) { @item.Email @if (string.IsNullOrEmpty(item.Id)) { - @Resources.GlobalTranslations.InactiveConnection + @WEB.Resources.GlobalTranslations.InactiveConnection } else { - @Resources.GlobalTranslations.ActiveConnection + @WEB.Resources.GlobalTranslations.ActiveConnection } } - + - @Resources.CardHeader.Invitations + @WEB.Resources.CardHeader.Invitations - - + - + @foreach (var item in Invite?.Invites ?? new List()) { @@ -50,11 +51,11 @@ @item.UserEmail @if (item.Accepted) { - @Resources.GlobalTranslations.InvitationAccepted + @WEB.Resources.GlobalTranslations.InvitationAccepted } else { - @Resources.GlobalTranslations.InvitationNotAccepted + @WEB.Resources.GlobalTranslations.InvitationNotAccepted }
} -
+
@code { [Parameter] public ProfileModel? profile { get; set; } = new(); + [Parameter][EditorRequired] public bool IsAuthenticated { get; set; } + [Parameter] public RenderControlCore CoreInvite { get; set; } = new(); + [Parameter] public RenderControlCore CorePartner { get; set; } = new(); private Partner? partner = new(); private InviteModel? Invite; - // private Loading? LoadingPartners; - // private Loading? LoadingInvites; private List NewInvites = new(); private List RemovedInvites = new(); protected override async Task LoadDataRender() { - LoadingInvites?.Start(); + // LoadingInvites?.Start(); var principal = await PrincipalApi.Get(IsAuthenticated); if (principal != null) Invite = await InviteApi.Invite_Get(principal.Email ?? throw new ValidationException("invalid email")); var isEmpty = Invite == null || !Invite.Invites.Any(); - LoadingInvites?.Finish(isEmpty, Resources.GlobalTranslations.NoPendingInvitations); + // LoadingInvites?.Finish(isEmpty, WEB.Resources.GlobalTranslations.NoPendingInvitations); } private void AddNewPartner() @@ -131,13 +133,13 @@ await InviteApi.Invite_Update(Invite); profile.Partners.Add(new Partner() { Email = invite.UserEmail, Id = userId }); - await ProfileApi.Profile_Update(profile); + await ProfileApi.Update(null, profile); - profile = await ProfileApi.Profile_Get(); //TODO update id field + profile = await ProfileApi.Get(null); //TODO update id field var principal = await PrincipalApi.Get(IsAuthenticated); var emailUser = principal?.Email; - await ProfileApi.Profile_UpdatePartner(userId, emailUser); + await ProfileApi.UpdatePartner(userId, emailUser); } else { diff --git a/MM.WEB/Modules/Profile/Components/PopupProfile.razor b/MM.WEB/Modules/Profile/Components/PopupProfile.razor index 9c532c4..11b0c69 100644 --- a/MM.WEB/Modules/Profile/Components/PopupProfile.razor +++ b/MM.WEB/Modules/Profile/Components/PopupProfile.razor @@ -76,7 +76,7 @@ }*@ - @view.Description + @view?.Description @@ -89,7 +89,7 @@ }*@ - @@ -133,7 +133,7 @@ - + diff --git a/MM.WEB/Modules/Profile/Components/ProfileReport.razor b/MM.WEB/Modules/Profile/Components/ProfileReport.razor index 2dfa689..864647a 100644 --- a/MM.WEB/Modules/Profile/Components/ProfileReport.razor +++ b/MM.WEB/Modules/Profile/Components/ProfileReport.razor @@ -29,7 +29,7 @@ - + diff --git a/MM.WEB/Modules/Profile/Core/DataHelper.cs b/MM.WEB/Modules/Profile/Core/DataHelper.cs index af7b5a8..5caefb5 100644 --- a/MM.WEB/Modules/Profile/Core/DataHelper.cs +++ b/MM.WEB/Modules/Profile/Core/DataHelper.cs @@ -6,427 +6,974 @@ public static class DataHelper { public static void AddLanguages(this ProfileModel profile, Country country) { - //https://en.wikipedia.org/wiki/List_of_official_languages - //https://en.wikipedia.org/wiki/List_of_official_languages_by_country_and_territory if (profile.Languages.Any()) return; switch (country) { - case Country.CHN: - profile.Languages = [Language.zh]; + case Country.Afghanistan: + profile.Languages = [Language.Persian, Language.Pashto]; break; - case Country.IND: - profile.Languages = [Language.HindiUrdu]; + case Country.AlandIslands: break; - case Country.USA: - profile.Languages = [Language.en]; + case Country.Albania: + profile.Languages = [Language.Albanian, Language.Italian]; break; - case Country.IDN: - profile.Languages = [Language.ms]; //Indonesian = It is a standardized variety of Malay + case Country.Algeria: + profile.Languages = [Language.Arabic, Language.French]; //Berber break; - case Country.PAK: - profile.Languages = [Language.HindiUrdu]; + case Country.AmericanSamoa: break; - case Country.NGA: - profile.Languages = [Language.en]; + case Country.Andorra: + profile.Languages = [Language.Catalan]; break; - case Country.BRA: - profile.Languages = [Language.pt]; + case Country.Angola: + profile.Languages = [Language.Portuguese]; break; - case Country.BGD: - //profile.Languages = new Language[] { Language.Bengali }; + case Country.Anguilla: break; - case Country.RUS: - profile.Languages = [Language.ru]; + case Country.AntiguaAndBarbuda: + profile.Languages = [Language.English]; break; - case Country.MEX: - profile.Languages = [Language.es]; + case Country.Argentina: + profile.Languages = [Language.Spanish]; break; - case Country.JPN: - //profile.Languages = new Language[] { Language.Japanese }; + case Country.Armenia: + profile.Languages = [Language.Armenian, Language.Russian]; break; - case Country.ETH: - //Oromo, Amharic + case Country.Aruba: break; - case Country.PHL: - //Filipino (Tagalog) + case Country.Australia: + profile.Languages = [Language.English]; break; - case Country.EGY: - profile.Languages = [Language.ar]; + case Country.Austria: + profile.Languages = [Language.German, Language.English]; break; - case Country.VNM: - //profile.Languages = new Language[] { Language.Vietnamese }; + case Country.Azerbaijan: + profile.Languages = [Language.Azerbaijani, Language.Russian]; break; - case Country.COD: - profile.Languages = [Language.fr]; + case Country.Bahamas: + profile.Languages = [Language.English]; break; - case Country.IRN: - profile.Languages = [Language.fa]; + case Country.Bahrain: + profile.Languages = [Language.Arabic]; break; - case Country.TUR: - profile.Languages = [Language.Turkish]; + case Country.Bangladesh: + profile.Languages = [Language.Bengali]; break; - case Country.DEU: - profile.Languages = [Language.de]; + case Country.Barbados: + profile.Languages = [Language.English]; break; - case Country.FRA: - profile.Languages = [Language.fr]; + case Country.Belarus: + profile.Languages = [Language.Belarusian, Language.Russian]; break; - case Country.GBR: - profile.Languages = [Language.en]; + case Country.Belgium: + profile.Languages = [Language.Dutch, Language.French, Language.German, Language.English]; break; - case Country.THA: - //Thai + case Country.Belize: + profile.Languages = [Language.English, Language.Spanish]; break; - case Country.ZAF: - //Zulu, Xhosa, Afrikaans, English + case Country.Benin: + profile.Languages = [Language.French]; break; - case Country.TZA: - profile.Languages = [Language.sw, Language.en]; + case Country.Bermuda: break; - case Country.ITA: - profile.Languages = [Language.it]; + case Country.Bhutan: + profile.Languages = [Language.Dzongkha]; break; - case Country.MMR: - //Burmese + case Country.Bolivia: + profile.Languages = [Language.Spanish]; //many others break; - case Country.KOR: - profile.Languages = [Language.Korean]; + case Country.CaribbeanNetherlands: break; - case Country.COL: - profile.Languages = [Language.es]; + case Country.BosniaAndHerzegovina: + profile.Languages = [Language.Bosnian, Language.Croatian, Language.Serbian]; break; - case Country.KEN: - profile.Languages = [Language.sw, Language.en]; + case Country.Botswana: + profile.Languages = [Language.English]; break; - case Country.ESP: - profile.Languages = [Language.es]; + case Country.BouvetIsland: break; - case Country.ARG: - profile.Languages = [Language.es]; + case Country.Brazil: + profile.Languages = [Language.Portuguese]; break; - case Country.DZA: - profile.Languages = [Language.ar]; + case Country.BritishIndianOceanTerritory: break; - case Country.SDN: - profile.Languages = [Language.ar]; + case Country.BritishVirginIslands: break; - case Country.UGA: - profile.Languages = [Language.en]; + case Country.Brunei: + profile.Languages = [Language.Malay]; break; - case Country.IRQ: - profile.Languages = [Language.ar]; + case Country.Bulgaria: + profile.Languages = [Language.Bulgarian]; break; - case Country.UKR: - //Ukrainian + case Country.BurkinaFaso: + profile.Languages = [Language.French]; break; - case Country.CAN: - profile.Languages = [Language.en]; + case Country.Burundi: + profile.Languages = [Language.French, Language.English, Language.Swahili]; //Kirundi break; - case Country.POL: - //Polish + case Country.Cambodia: + profile.Languages = [Language.CentralKhmer]; break; - case Country.MAR: - profile.Languages = [Language.ar]; + case Country.Cameroon: + profile.Languages = [Language.English, Language.French]; break; - case Country.UZB: - //Uzbek + case Country.Canada: + profile.Languages = [Language.English, Language.French]; break; - case Country.SAU: - profile.Languages = [Language.ar]; + case Country.CapeVerde: + profile.Languages = [Language.Portuguese]; break; - case Country.PER: - profile.Languages = [Language.es]; + case Country.CaymanIslands: break; - case Country.AGO: - profile.Languages = [Language.pt]; + case Country.CentralAfricanRepublic: + profile.Languages = [Language.French, Language.Sango]; break; - case Country.AFG: - profile.Languages = [Language.fa]; //Dari, which is a variety of and mutually intelligible with Persian - //Pashto, Dari + case Country.Chad: + profile.Languages = [Language.Arabic, Language.French]; break; - case Country.MYS: - profile.Languages = [Language.ms]; + case Country.Chile: + profile.Languages = [Language.Spanish]; break; - case Country.MOZ: - profile.Languages = [Language.pt]; + case Country.China: + profile.Languages = [Language.Chinese]; break; - case Country.GHA: - profile.Languages = [Language.en]; + case Country.HongKong: + profile.Languages = [Language.Chinese, Language.English]; break; - case Country.YEM: - profile.Languages = [Language.ar]; + case Country.Macao: + profile.Languages = [Language.Chinese, Language.Portuguese]; break; - case Country.NPL: - //Nepali + case Country.ChristmasIsland: + profile.Languages = [Language.English, Language.Chinese, Language.Malay]; break; - case Country.VEN: - profile.Languages = [Language.es]; + case Country.CocosKeelingIslands: + profile.Languages = [Language.English, Language.Malay]; break; - case Country.CIV: - profile.Languages = [Language.fr]; + case Country.Colombia: + profile.Languages = [Language.Spanish]; break; - case Country.MDG: - //Malagasy (official, and national language), French (official). + case Country.Comoros: + profile.Languages = [Language.Arabic, Language.French]; //Comorian break; - case Country.AUS: - profile.Languages = [Language.en]; + case Country.RepublicOfTheCongo: + profile.Languages = [Language.French]; break; - case Country.PRK: - profile.Languages = [Language.Korean]; + case Country.CookIslands: + profile.Languages = [Language.English, Language.Maori]; + break; + + case Country.CostaRica: + profile.Languages = [Language.Spanish]; break; - case Country.CMR: - profile.Languages = [Language.fr]; + case Country.Croatia: + profile.Languages = [Language.Croatian, Language.English]; break; - case Country.NER: - profile.Languages = [Language.fr]; + case Country.Cuba: + profile.Languages = [Language.Spanish]; break; - case Country.TWN: - profile.Languages = [Language.zh]; + case Country.Curacao: break; - case Country.LKA: - //Sinhala + case Country.Cyprus: + profile.Languages = [Language.Greek, Language.Turkish, Language.English]; break; - case Country.BFA: - profile.Languages = [Language.fr]; + case Country.Czechia: + profile.Languages = [Language.Czech, Language.Slovak]; break; - case Country.MWI: - profile.Languages = [Language.en]; + case Country.DemocraticRepublicOfTheCongo: + profile.Languages = [Language.French]; break; - case Country.MLI: - profile.Languages = [Language.fr]; + case Country.Denmark: + profile.Languages = [Language.Danish]; break; - case Country.CHL: - profile.Languages = [Language.es]; + case Country.Djibouti: + profile.Languages = [Language.Arabic, Language.French]; break; - case Country.KAZ: - //Kazakh, Russian + case Country.Dominica: + profile.Languages = [Language.English]; break; - case Country.ROU: - profile.Languages = [Language.ro]; + case Country.DominicanRepublic: + profile.Languages = [Language.Spanish]; break; - case Country.ZMB: - profile.Languages = [Language.en]; + case Country.EastTimor: + profile.Languages = [Language.Portuguese]; //Tetum break; - case Country.SYR: - profile.Languages = [Language.ar]; + case Country.Ecuador: + profile.Languages = [Language.Spanish]; break; - case Country.ECU: - profile.Languages = [Language.es]; + case Country.Egypt: + profile.Languages = [Language.Arabic, Language.English]; break; - case Country.NLD: - profile.Languages = [Language.nl]; + case Country.ElSalvador: + profile.Languages = [Language.Spanish]; break; - case Country.SEN: - profile.Languages = [Language.fr]; + case Country.EquatorialGuinea: + profile.Languages = [Language.French, Language.Portuguese, Language.Spanish]; break; - case Country.GTM: - profile.Languages = [Language.es]; + case Country.Eritrea: + profile.Languages = [Language.Tigrinya, Language.Arabic, Language.Italian]; break; - case Country.TCD: - profile.Languages = [Language.fr, Language.ar]; + case Country.Estonia: + profile.Languages = [Language.Estonian, Language.Russian]; break; - case Country.SOM: - profile.Languages = [Language.Somali]; + case Country.Eswatini: + profile.Languages = [Language.English]; //Swazi break; - case Country.ZWE: - //Shona, English + case Country.Ethiopia: + profile.Languages = [Language.Afar, Language.Amharic, Language.Oromo, Language.Somali, Language.Tigrinya]; break; - case Country.KHM: - //Khmer + case Country.FalklandIslands: break; - case Country.SSD: - profile.Languages = [Language.en]; + case Country.FaroeIslands: break; - case Country.RWA: - //Kinyarwanda + case Country.Fiji: + profile.Languages = [Language.English, Language.Fijian, Language.Hindi]; break; - case Country.GIN: - profile.Languages = [Language.fr]; + case Country.Finland: + profile.Languages = [Language.Finnish, Language.Swedish, Language.English]; break; - case Country.BDI: - //Kirundi + case Country.France: + profile.Languages = [Language.French, Language.Occitan]; break; - case Country.BEN: - profile.Languages = [Language.fr]; + case Country.FrenchGuiana: break; - case Country.BOL: - profile.Languages = [Language.es]; + case Country.FrenchPolynesia: break; - case Country.TUN: - profile.Languages = [Language.ar]; + case Country.FrenchSouthernAndAntarcticLands: break; - case Country.HTI: - profile.Languages = [Language.fr]; + case Country.Gabon: + profile.Languages = [Language.French]; break; - case Country.BEL: - profile.Languages = [Language.nl]; + case Country.Gambia: + profile.Languages = [Language.English]; break; - case Country.JOR: - profile.Languages = [Language.ar]; + case Country.Georgia: + profile.Languages = [Language.Georgian, Language.Russian]; break; - case Country.CUB: - profile.Languages = [Language.es]; + case Country.Germany: + profile.Languages = [Language.German, Language.English]; break; - case Country.GRC: + case Country.Ghana: + profile.Languages = [Language.English]; + break; + + case Country.Gibraltar: + break; + + case Country.Greece: profile.Languages = [Language.Greek]; break; - case Country.DOM: - profile.Languages = [Language.es]; + case Country.Greenland: + break; + + case Country.Grenada: + profile.Languages = [Language.English]; + break; + + case Country.Guadeloupe: + break; + + case Country.Guam: + break; + + case Country.Guatemala: + profile.Languages = [Language.Spanish]; + break; + + case Country.Guernsey: + break; + + case Country.Guinea: + profile.Languages = [Language.French]; + break; + + case Country.GuineaBissau: + profile.Languages = [Language.Portuguese]; + break; + + case Country.Guyana: + profile.Languages = [Language.English]; + break; + + case Country.Haiti: + profile.Languages = [Language.French, Language.Haitian]; + break; + + case Country.HeardIslandAndMcDonaldIslands: + break; + + case Country.Honduras: + profile.Languages = [Language.Spanish]; + break; + + case Country.Hungary: + profile.Languages = [Language.Hungarian]; + break; + + case Country.Iceland: + profile.Languages = [Language.Icelandic]; + break; + + case Country.India: + profile.Languages = [Language.Hindi, Language.English]; + break; + + case Country.Indonesia: + profile.Languages = [Language.Indonesian, Language.Malay, Language.Javanese, Language.Sundanese]; //Madurese, Minangkabau + break; + + case Country.Iran: + profile.Languages = [Language.Persian]; + break; + + case Country.Iraq: + profile.Languages = [Language.Arabic, Language.Kurdish]; + break; + + case Country.Ireland: + profile.Languages = [Language.Irish, Language.English]; + break; + + case Country.IsleOfMan: + break; + + case Country.Israel: + profile.Languages = [Language.Hebrew, Language.Russian, Language.English]; + break; + + case Country.Italy: + profile.Languages = [Language.Italian]; + break; + + case Country.IvoryCoast: + profile.Languages = [Language.French]; + break; + + case Country.Jamaica: + profile.Languages = [Language.English]; + break; + + case Country.Japan: + profile.Languages = [Language.Japanese]; + break; + + case Country.Jersey: + break; + + case Country.Jordan: + profile.Languages = [Language.Arabic]; + break; + + case Country.Kazakhstan: + profile.Languages = [Language.Kazakh, Language.Russian]; + break; + + case Country.Kenya: + profile.Languages = [Language.English, Language.Swahili]; + break; + + case Country.Kiribati: + profile.Languages = [Language.English]; //Gilbertese + break; + + case Country.Kosovo: + profile.Languages = [Language.Albanian, Language.Serbian]; + break; + + case Country.Kuwait: + profile.Languages = [Language.Arabic]; + break; + + case Country.Kyrgyzstan: + profile.Languages = [Language.Kirghiz, Language.Russian]; + break; + + case Country.Laos: + profile.Languages = [Language.Lao]; + break; + + case Country.Latvia: + profile.Languages = [Language.Latvian, Language.Russian]; + break; + + case Country.Lebanon: + profile.Languages = [Language.Arabic, Language.English, Language.French]; + break; + + case Country.Lesotho: + profile.Languages = [Language.SouthernSotho, Language.English]; + break; + + case Country.Liberia: + profile.Languages = [Language.English]; + break; + + case Country.Libya: + profile.Languages = [Language.Arabic]; + break; + + case Country.Liechtenstein: + profile.Languages = [Language.German]; + break; + + case Country.Lithuania: + profile.Languages = [Language.Lithuanian, Language.Russian]; + break; + + case Country.Luxembourg: + profile.Languages = [Language.French, Language.German, Language.Luxembourgish, Language.English, Language.Portuguese]; + break; + + case Country.Madagascar: + profile.Languages = [Language.French, Language.Malagasy]; + break; + + case Country.Malawi: + profile.Languages = [Language.English, Language.Chichewa]; + break; + + case Country.Malaysia: + profile.Languages = [Language.Malay, Language.Chinese, Language.Tamil, Language.English]; //Cantonese + break; + + case Country.Maldives: + profile.Languages = [Language.Divehi, Language.English]; + break; + + case Country.Mali: + profile.Languages = [Language.Bambara, Language.Fulah]; //Bobo, Bozo, Dogon, Hassaniya, Kassonke, Maninke, Minyanka, Senufo, Songhay languages, Soninke, Tamasheq + break; + + case Country.Malta: + profile.Languages = [Language.Maltese, Language.English]; + break; + + //Sovereign Military Order of Malta + + case Country.MarshallIslands: + profile.Languages = [Language.English, Language.Marshallese]; + break; + + case Country.Martinique: + break; + + case Country.Mauritania: + profile.Languages = [Language.Arabic]; + break; + + case Country.Mauritius: + profile.Languages = [Language.English]; //Mauritian Creole (Also known as 'Morisien') + break; + + case Country.Mayotte: + break; + + case Country.Mexico: + profile.Languages = [Language.Spanish]; + break; + + case Country.Moldova: + profile.Languages = [Language.Romanian]; + break; + + case Country.FederatedStatesOfMicronesia: + profile.Languages = [Language.English]; + break; + + case Country.PrincipalityOfMonaco: + profile.Languages = [Language.French]; //Monégasque + break; + + case Country.Mongolia: + profile.Languages = [Language.Mongolian]; + break; + + case Country.Montenegro: + //Montenegrin + break; + + case Country.Montserrat: + break; + + case Country.Morocco: + profile.Languages = [Language.Arabic]; //Berber + break; + + case Country.Mozambique: + profile.Languages = [Language.Portuguese]; + break; + + case Country.Myanmar: + profile.Languages = [Language.Burmese, Language.English]; + break; + + case Country.Namibia: + profile.Languages = [Language.English]; + break; + + case Country.Nauru: + profile.Languages = [Language.English, Language.Nauru]; + break; + + case Country.Nepal: + profile.Languages = [Language.Nepali]; + break; + + case Country.Netherlands: + profile.Languages = [Language.Dutch, Language.English]; + break; + + case Country.NewCaledonia: + break; + + case Country.NewZealand: + profile.Languages = [Language.English, Language.Maori]; + break; + + case Country.Nicaragua: + profile.Languages = [Language.Spanish]; + break; + + case Country.Niger: + profile.Languages = [Language.French]; + break; + + case Country.Nigeria: + profile.Languages = [Language.English, Language.Hausa]; break; - case Country.CZE: - //Czech + case Country.Niue: + profile.Languages = [Language.English]; //Niuean break; - case Country.SWE: + case Country.NorfolkIsland: + profile.Languages = [Language.English]; //Norfuk + break; + + case Country.NorthKorea: + profile.Languages = [Language.Korean]; + break; + + case Country.NorthMacedonia: + profile.Languages = [Language.Albanian]; //Macedonian + break; + + //Northern Cyprus + + case Country.NorthernMarianaIslands: + break; + + case Country.Norway: + profile.Languages = [Language.NorwegianBokmål, Language.NorwegianNynorsk, Language.English]; + break; + + case Country.Oman: + profile.Languages = [Language.Arabic]; + break; + + case Country.Pakistan: + profile.Languages = [Language.Urdu, Language.English]; + break; + + case Country.Palau: + profile.Languages = [Language.English]; //Palauan + break; + + case Country.Palestine: + profile.Languages = [Language.Arabic, Language.English, Language.Hebrew]; + break; + + case Country.Panama: + profile.Languages = [Language.Spanish]; + break; + + case Country.PapuaNewGuinea: + profile.Languages = [Language.English, Language.HiriMotu]; //Tok Pisin + break; + + case Country.Paraguay: + profile.Languages = [Language.Spanish, Language.Guarani]; + break; + + case Country.Peru: + profile.Languages = [Language.Spanish]; + break; + + case Country.Philippines: + profile.Languages = [Language.English]; //Filipino + break; + + case Country.PitcairnIslands: + break; + + case Country.Poland: + profile.Languages = [Language.Polish, Language.English]; + break; + + case Country.Portugal: + profile.Languages = [Language.Portuguese, Language.English]; + break; + + case Country.PuertoRico: + break; + + case Country.Qatar: + profile.Languages = [Language.Arabic]; + break; + + case Country.SouthKorea: + profile.Languages = [Language.Korean]; + break; + + case Country.Reunion: + break; + + case Country.Romania: + profile.Languages = [Language.Romanian]; + break; + + case Country.Russia: + profile.Languages = [Language.Russian]; + break; + + case Country.Rwanda: + profile.Languages = [Language.English, Language.French, Language.Kinyarwanda, Language.Swahili]; + break; + + //Sahrawi Arab Democratic Republic - Arabic, Spanish + + case Country.SaintBarthelemy: + break; + + case Country.SaintHelenaAscensionAndTristanDaCunha: + break; + + case Country.SaintKittsAndNevis: + profile.Languages = [Language.English]; + break; + + case Country.SaintLucia: + profile.Languages = [Language.English]; + break; + + case Country.SaintMartin: + break; + + case Country.SaintPierreAndMiquelon: + break; + + case Country.SaintVincentAndTheGrenadines: + profile.Languages = [Language.English]; + break; + + case Country.Samoa: + profile.Languages = [Language.English, Language.Samoan]; + break; + + case Country.SanMarino: + profile.Languages = [Language.Italian]; + break; + + case Country.SaoTomeAndPrincipe: + profile.Languages = [Language.Portuguese]; + break; + + case Country.Sark: + break; + + case Country.SaudiArabia: + profile.Languages = [Language.Arabic, Language.Bengali]; //Filipino + break; + + case Country.Senegal: + profile.Languages = [Language.French]; + break; + + case Country.Serbia: + profile.Languages = [Language.Serbian]; + break; + + case Country.Seychelles: + profile.Languages = [Language.English, Language.French]; //Seychellois Creole + break; + + case Country.SierraLeone: + profile.Languages = [Language.English]; + break; + + case Country.Singapore: + profile.Languages = [Language.English, Language.Malay, Language.Chinese, Language.Tamil]; + break; + + case Country.SintMaarten: + break; + + case Country.Slovakia: + profile.Languages = [Language.Slovak]; + break; + + case Country.Slovenia: + profile.Languages = [Language.Slovenian]; + break; + + case Country.SolomonIslands: + profile.Languages = [Language.English]; + break; + + case Country.Somalia: + profile.Languages = [Language.Somali, Language.Arabic]; + break; + + //Somaliland + + case Country.SouthAfrica: + profile.Languages = [Language.Afrikaans, Language.English]; //many others + break; + + case Country.SouthGeorgiaAndSouthSandwichIslands: + break; + + //South Ossetia + + case Country.SouthSudan: + profile.Languages = [Language.English]; + break; + + case Country.Spain: + profile.Languages = [Language.Spanish]; + break; + + case Country.SriLanka: + profile.Languages = [Language.Sinhala, Language.Tamil, Language.English]; + break; + + case Country.Sudan: + profile.Languages = [Language.Arabic, Language.English]; + break; + + case Country.Suriname: + profile.Languages = [Language.Dutch]; + break; + + case Country.Svalbard: + break; + + case Country.Sweden: profile.Languages = [Language.Swedish]; break; - case Country.PRT: - profile.Languages = [Language.pt]; + case Country.Switzerland: + profile.Languages = [Language.French, Language.German, Language.Italian, Language.Romansh]; + break; + + case Country.Syria: + profile.Languages = [Language.Arabic]; + break; + + case Country.Taiwan: + profile.Languages = [Language.Chinese]; + break; + + case Country.Tajikistan: + profile.Languages = [Language.Tajik, Language.Russian]; + break; + + case Country.Thailand: + profile.Languages = [Language.Thai, Language.Burmese]; + break; + + case Country.Togo: + profile.Languages = [Language.French]; + break; + + case Country.Tokelau: + profile.Languages = [Language.English]; //Tokelauan + break; + + case Country.Tonga: + profile.Languages = [Language.English]; //Tongan + break; + + //Transnistria + + case Country.TrinidadAndTobago: + profile.Languages = [Language.English]; //Trinidadian Creole + break; + + case Country.Tunisia: + profile.Languages = [Language.Arabic]; + break; + + case Country.Turkey: + profile.Languages = [Language.Turkish]; + break; + + case Country.Turkmenistan: + profile.Languages = [Language.Turkmen, Language.Russian]; + break; + + case Country.TurksAndCaicosIslands: + break; + + case Country.Tuvalu: + profile.Languages = [Language.English]; //Tuvaluan + break; + + case Country.Uganda: + profile.Languages = [Language.English, Language.Swahili]; + break; + + case Country.Ukraine: + profile.Languages = [Language.Ukrainian]; + break; + + case Country.UnitedArabEmirates: + profile.Languages = [Language.Arabic, Language.English]; + break; + + case Country.UnitedKingdom: + profile.Languages = [Language.English]; + break; + + case Country.Tanzania: break; - case Country.AZE: - //Azerbaijani + case Country.UnitedStatesMinorOutlyingIslands: break; - case Country.HUN: - //Hungarian + case Country.UnitedStatesOfAmerica: + profile.Languages = [Language.English, Language.Spanish]; break; - case Country.HND: - profile.Languages = [Language.es]; + case Country.VirginIslands: break; - case Country.ISR: - //Hebrew + case Country.Uruguay: + profile.Languages = [Language.Spanish]; break; - case Country.TJK: - profile.Languages = [Language.ru]; + case Country.Uzbekistan: + profile.Languages = [Language.Uzbek, Language.Russian]; break; - case Country.BLR: - profile.Languages = [Language.ru]; + case Country.Vanuatu: + profile.Languages = [Language.English, Language.French, Language.Bislama]; break; - case Country.ARE: - profile.Languages = [Language.ar]; + case Country.VaticanCity: + profile.Languages = [Language.Italian, Language.Latin]; //Swiss German break; - case Country.PNG: - profile.Languages = [Language.en]; + case Country.Venezuela: + profile.Languages = [Language.Spanish]; break; - case Country.AUT: - profile.Languages = [Language.de]; + case Country.Vietnam: + profile.Languages = [Language.Vietnamese]; break; - case Country.CHE: - profile.Languages = [Language.de]; + case Country.WallisAndFutuna: break; - case Country.SLE: - profile.Languages = [Language.en]; + case Country.WesternSahara: break; - case Country.TGO: - profile.Languages = [Language.fr]; + case Country.Yemen: + profile.Languages = [Language.Arabic]; break; - case Country.HKG: - //Cantonese + case Country.Zambia: + profile.Languages = [Language.English]; break; - case Country.PRY: - profile.Languages = [Language.es]; + case Country.Zimbabwe: + profile.Languages = [Language.English, Language.NorthNdebele, Language.Shona, Language.SouthernSotho, Language.Tonga, Language.Tswana, Language.Venda, Language.Xhosa]; //many others break; default: diff --git a/MM.WEB/Modules/Profile/Core/MapaApi.cs b/MM.WEB/Modules/Profile/Core/MapaApi.cs index 9be5187..5265707 100644 --- a/MM.WEB/Modules/Profile/Core/MapaApi.cs +++ b/MM.WEB/Modules/Profile/Core/MapaApi.cs @@ -3,16 +3,23 @@ namespace MM.WEB.Modules.Profile.Core { - public class MapApi(IHttpClientFactory http, IMemoryCache memoryCache) : ApiCosmos(http, memoryCache, "HereJson") + public class MapApi(IHttpClientFactory http, IMemoryCache memoryCache) : ApiCosmos(http, memoryCache, "MapApi") { public struct MapEndpoint { - public static string GetLocation(double Latitude, double Longitude) => $"External/GetLocation/{Latitude.ToString(CultureInfo.InvariantCulture)}/{Longitude.ToString(CultureInfo.InvariantCulture)}"; + public static string GetLocationHere(double Latitude, double Longitude) => $"location/here/{Latitude.ToString(CultureInfo.InvariantCulture)}/{Longitude.ToString(CultureInfo.InvariantCulture)}"; + + public static string GetLocationGoogle(double Latitude, double Longitude) => $"location/google/{Latitude.ToString(CultureInfo.InvariantCulture)}/{Longitude.ToString(CultureInfo.InvariantCulture)}"; + } + + public async Task GetLocationHere(double Latitude, double Longitude) + { + return await GetAsync(MapEndpoint.GetLocationHere(Latitude, Longitude), null); } - public async Task GetLocation(double Latitude, double Longitude) + public async Task GetLocationGoogle(double Latitude, double Longitude) { - return await GetAsync(MapEndpoint.GetLocation(Latitude, Longitude), null); + return await GetAsync(MapEndpoint.GetLocationGoogle(Latitude, Longitude)); } } } \ No newline at end of file diff --git a/MM.WEB/Modules/Profile/Core/ProfileApi.cs b/MM.WEB/Modules/Profile/Core/ProfileApi.cs index 03bfb0d..9093349 100644 --- a/MM.WEB/Modules/Profile/Core/ProfileApi.cs +++ b/MM.WEB/Modules/Profile/Core/ProfileApi.cs @@ -11,7 +11,7 @@ public struct ProfileEndpoint public const string Get = "profile/get"; public const string Update = "profile/update"; public const string UpdateLooking = "profile/update-preference"; - //public const string UpdatePartner = "Profile/UpdatePatner"; + public static string UpdatePartner(string? id, string? email) => $"profile/update-partner?id={id}&email={email}"; //public const string ListMatch = "Profile/ListMatch"; //public const string ListSearch = "Profile/ListSearch"; @@ -57,11 +57,11 @@ public struct ProfileEndpoint //} } - //public async Task Profile_UpdatePartner(string id, string? email) - //{ - // if (string.IsNullOrEmpty(email)) throw new ArgumentNullException(nameof(email)); + public async Task UpdatePartner(string? id, string? email) + { + if (string.IsNullOrEmpty(email)) throw new ArgumentNullException(nameof(email)); - // await PutAsync(ProfileEndpoint.UpdatePartner, false, new { id, email }, null, null); - //} + await PutAsync(ProfileEndpoint.UpdatePartner(id, email), null, null); + } } } \ No newline at end of file diff --git a/MM.WEB/Modules/Profile/Profile.razor b/MM.WEB/Modules/Profile/Profile.razor new file mode 100644 index 0000000..4c3ebe5 --- /dev/null +++ b/MM.WEB/Modules/Profile/Profile.razor @@ -0,0 +1,308 @@ +@page "/profile" + +@using MM.Shared.Models.Profile; +@using MM.WEB.Modules.Profile.Components +@using MM.WEB.Modules.Profile.Core; +@attribute [Authorize] +@inherits PageCore + +@inject ProfileApi ProfileApi + + + + Seu Perfil (@profile?.NickName) + + @foreach (var item in imageDataUriGallery) + { + + + + } + + + + + + + + + + + + + + + + + + + + @if (profile?.Modality == Modality.Matchmaker) + { + @* + + @string.Format(Resources.CardHeader.IndexHighlights, GetSuggestionTitle()) + + + + + @foreach (var item in lstDestaques) + { + + + @* + + *@@* + @item.NickName, @item.Age + @if (item.ActivityStatus == ActivityStatus.Today) + { + + + + } + else if (item.ActivityStatus == ActivityStatus.Week) + { + + + + } + else if (item.ActivityStatus == ActivityStatus.Month) + { + + + + } + else + { + + + + } + + + + + + + + } + + + + + + @Resources.CardHeader.ProfileIndexInteractions + + + + + + + + + + + + + + + + + + + + *@ + } + else if (profile?.Modality == Modality.RelationshipAnalysis) + { + Seu Parceiro (@(view?.NickName ?? "...")) + + + + + + + @if (view != null) + { + + @foreach (var item in imageDataUriGallery) + { + + + + } + + } + + + @if (view != null) + { + @* + @view.NickName + *@ + @* + @view?.GetLocation(ProfileModel.LocationType.City) + *@ + @* @if (view.ActivityStatus == ActivityStatus.Today) + { + + logado hoje + + } + else if (view.ActivityStatus == ActivityStatus.Week) + { + + logado esta semana + + } + else if (view.ActivityStatus == ActivityStatus.Month) + { + + logado este mês + + } + else + { + + usuário desativado + + } *@ + @* @if (view.Reports.Any()) + { + + @foreach (var item in view?.Reports ?? Array.Empty()) + { + + @item.Type.GetName() + + } + + }*@ + } + + + + + + + + + } + + + + +@code +{ + private ProfileModel? profile; + public RenderControlCore? Core { get; set; } = new(); + + private ProfileModel? view; + private List affinities = new(); + //private List lstDestaques = new(); + + string? selectedImage; + string[] imageDataUriGallery = new string[] { }; + + //private bool ProfileLoading = true; + //private bool ViewLoading = true; + // private bool SuggestionsLoading = true; + + // public Loading ProfileLoading { get; set; } = default!; + // public Loading ViewLoading { get; set; } = default!; + + protected override async Task LoadDataRender() + { + try + { + if (IsAuthenticated) + { + // ProfileLoading.Start(); + profile = await ProfileApi.Get(Core); + // ProfileLoading.Finish(profile == null, "Perfil não encontrado. Favor, realizar seu cadastro para poder usar todas as funcionalidades"); + // ProfileLoading.Finish(profile?.Preference == null, "Preferências não encontradas. Favor, realizar seu preenchimento para poder usar todas as funcionalidades"); + + if (profile != null) + { + if (profile.Modality == Modality.RelationshipAnalysis) + { + // ViewLoading.Start(); + var partner = profile.Partners.FirstOrDefault(w => !string.IsNullOrEmpty(w.Id)); + // view = await ProfileApi.Profile_GetView(partner?.Id); + // ViewLoading.Finish(view == null); + } + else + { + // SuggestionsLoading = true; + //lstDestaques = await Http.Public_ListDestaques(SessionStorage); + //lstDestaques = await Http.Profile_ListSearch(SessionStorage); + // SuggestionsLoading = false; + } + + imageDataUriGallery = new string[] { profile.GetMainPhoto() }.Concat(profile.GetGalleryPhotos()).ToArray(); + + if (view != null) + { + affinities = AffinityCore.GetAffinity(profile, view); + } + } + else + { + imageDataUriGallery = new string[] { ImageHelper.GetNoUserPhoto }; + } + + selectedImage = imageDataUriGallery.First(); + + //ProfileLoading = false; + //ViewLoading = false; + // SuggestionsLoading = false; + } + } + catch (Exception ex) + { + ex.ProcessException(Toast, Logger); + } + } + + private string GetSuggestionTitle() + { + if (profile?.Preference?.Region == null) return ""; + + switch (profile.Preference.Region) + { + case Region.City: + return $"{profile.Preference.Region.GetName()} - {profile?.GetLocation(ProfileModel.LocationType.City)}"; + case Region.State: + return $"{profile.Preference.Region.GetName()} - {profile?.GetLocation(ProfileModel.LocationType.State)}"; + case Region.Country: + return $"{profile.Preference.Region.GetName()} - {profile?.GetLocation(ProfileModel.LocationType.Country)}"; + case Region.World: + return $"{profile.Preference.Region.GetName()}"; + default: + return ""; + } + } +} \ No newline at end of file diff --git a/MM.WEB/Modules/Profile/ProfileData.razor b/MM.WEB/Modules/Profile/ProfileData.razor index 9cd3270..2ee6b13 100644 --- a/MM.WEB/Modules/Profile/ProfileData.razor +++ b/MM.WEB/Modules/Profile/ProfileData.razor @@ -1,4 +1,4 @@ -@page "/Profile/Data" +@page "/profile/data" @using MM.Shared.Models.Profile; @using MM.WEB.Modules.Profile.Components @using MM.WEB.Modules.Shared.Popup; @@ -8,194 +8,230 @@ -
- - - - - - @if (profile?.Modality == Modality.RelationshipAnalysis) - { - - } -
- @if (SelectedTab == Tabs.Basic) - { - - - - - - - - - - - - - - - - - } - else if (SelectedTab == Tabs.Bio) - { - - @WEB.Resources.GlobalTranslations.ProfileDataBioTip1 - - - - - - - - - - - - - - - - - - - - - - - - - @WEB.Resources.CardHeader.ProfileOptionalSection - - + + + + @MM.Shared.Enums.Resources.Section.Basic + @if (!IsValid(Tabs.Basic)) + { + + } + + + @MM.Shared.Enums.Resources.Section.Bio + @if (!IsValid(Tabs.Bio)) + { + + } + + + @MM.Shared.Enums.Resources.Section.Lifestyle + @if (!IsValid(Tabs.Lifestyle)) + { + + } + + + @MM.Shared.Enums.Resources.Section.Personality + @if (!IsValid(Tabs.Personality)) + { + + } + + + @MM.Shared.Enums.Resources.Section.Interest + @if (!IsValid(Tabs.Interests)) + { + + } + + @if (profile?.Modality == Modality.RelationshipAnalysis) + { + + @WEB.Resources.GlobalTranslations.MyRelationship + @if (!IsValid(Tabs.MyRelationship)) + { + + } + + } + + + + + + + + + + + + + + + + + + + + + - @WEB.Resources.GlobalTranslations.ProfileDataBioTip2 + @WEB.Resources.GlobalTranslations.ProfileDataBioTip1 - + + - + + + + + + + + + + + + + - - - } - else if (SelectedTab == Tabs.Lifestyle) - { - - - - - - - - - - - - - - - - } - else if (SelectedTab == Tabs.Personality) - { - - @WEB.Resources.GlobalTranslations.ProfileDataPersonTip1 - - - - - - - - - - - - - - } - else if (SelectedTab == Tabs.Interests) - { - - @WEB.Resources.CardHeader.Maximum3Items - - - - - - - - - - - - - - - - } - else if (SelectedTab == Tabs.MyRelationship) - { - - } + + + @WEB.Resources.CardHeader.ProfileOptionalSection + + + + @WEB.Resources.GlobalTranslations.ProfileDataBioTip2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @WEB.Resources.GlobalTranslations.ProfileDataPersonTip1 + + + + + + + + + + + + + + + + + + @WEB.Resources.CardHeader.Maximum3Items + + + + + + + + + + + + + + + + + + + + +
- -
@@ -229,10 +265,11 @@ private BasicModal? help; private FluentValidationValidator? _validator; - // private Loading? LoadingProfile; public ZodiacType ZodiacType { get; set; } = ZodiacType.WesternZodiac; + public string? Tab { get; set; } = "Basic"; + private enum Tabs { Basic, @@ -243,14 +280,7 @@ MyRelationship } - private Tabs SelectedTab = Tabs.Basic; - - private void ChangeOrder(Tabs tab) - { - SelectedTab = tab; - } - - private Color GetTabColor(Tabs tab) + private bool IsValid(Tabs tab) { var valid = false; @@ -280,6 +310,6 @@ _validator?.Validate(options => options.IncludeAllRuleSets()); - return valid ? Color.Secondary : Color.Danger; + return valid; } } \ No newline at end of file diff --git a/MM.WEB/Modules/Profile/ProfileData.razor.cs b/MM.WEB/Modules/Profile/ProfileData.razor.cs index cd428ac..ad3b2cc 100644 --- a/MM.WEB/Modules/Profile/ProfileData.razor.cs +++ b/MM.WEB/Modules/Profile/ProfileData.razor.cs @@ -38,53 +38,53 @@ protected override async Task LoadDataRender() private async Task SetLocation(ProfileModel profile) { - if (profile != null /*&& !profile.Longitude.HasValue*/) + try { - var window = await JsRuntime.Window(); //todo: remove this component - var navigator = await window.Navigator(); - var position = await navigator.Geolocation.GetCurrentPosition(); - - if (position.Error != null) + if (profile != null /*&& !profile.Longitude.HasValue*/) { - await Toast.Warning(position.Error.Message); - } - else if (position.Location != null) - { - GPS ??= new(); - - GPS.Latitude = position.Location.Coords.Latitude; - GPS.Longitude = position.Location.Coords.Longitude; - GPS.Accuracy = position.Location.Coords.Accuracy; + var window = await JsRuntime.Window(); //todo: remove this component + var navigator = await window.Navigator(); + var position = await navigator.Geolocation.GetCurrentPosition(); - //TODO: chamar código da api - var here = await MapApi.GetLocation(GPS.Latitude, GPS.Longitude); - if (here != null && here.items.Any()) + if (position.Error != null) { - var address = here.items[0].address; - profile.Location = address?.GetLocation(); - - var country = (Country)Enum.Parse(typeof(Country), address.countryCode); - - profile.AddLanguages(country); + await Toast.Warning(position.Error.Message); + } + else if (position.Location != null) + { + GPS ??= new(); + + GPS.Latitude = position.Location.Coords.Latitude; + GPS.Longitude = position.Location.Coords.Longitude; + GPS.Accuracy = position.Location.Coords.Accuracy; + + //TODO: chamar código da api + var here = await MapApi.GetLocationHere(GPS.Latitude, GPS.Longitude); + if (here != null && here.items.Count != 0) + { + var address = here.items[0].address; + profile.Location = address?.GetLocation(); + + var obj = EnumHelper.GetList().Single(s => s.Tips == (address?.countryCode ?? "USA")); + var country = (Country)obj.Value; + + profile.AddLanguages(country); + } + else + { + profile.Location = "Unknown Location"; + } } else { - profile.Location = "Unknown Location"; + await Toast.Warning(GlobalTranslations.UnableDetectGps); } - - //profile.Longitude = GPS.Longitude; - //profile.Latitude = GPS.Latitude; - - //if (GPS.Accuracy > 500) - //{ - // Toast.ShowWarning("", $"A posição do GPS foi recuperada, mas a precisão é de apenas: {Math.Round(GPS.Accuracy / 1000, 1)} km. Tente novamente mais tarde ou use um dispositivo mais preciso."); - //} - } - else - { - await Toast.Warning(GlobalTranslations.UnableDetectGps); } } + catch (Exception ex) + { + ex.ProcessException(Toast, Logger); + } } private async Task HandleValidSubmit() @@ -99,7 +99,7 @@ private async Task HandleValidSubmit() profile = await ProfileApi.Get(Core); //TODO update id field - if (profile.Modality == Modality.Matchmaker) + if (profile?.Modality == Modality.Matchmaker) { foreach (var item in profile.Partners) { diff --git a/MM.WEB/Modules/Profile/ProfilePreference.razor b/MM.WEB/Modules/Profile/ProfilePreference.razor index 4802edb..f8c1425 100644 --- a/MM.WEB/Modules/Profile/ProfilePreference.razor +++ b/MM.WEB/Modules/Profile/ProfilePreference.razor @@ -14,7 +14,6 @@ - @if (preference != null) @@ -27,17 +26,17 @@ CssIcon="@Blazorise.Icons.FontAwesome.FontAwesomeIcons.MapMarkedAlt" ShowHelper="false" Required="true" CustomInfo="@($"{GlobalTranslations.YourCurrentLocation} {profile?.Location}")"> - - - - - @@ -46,10 +45,10 @@ { - - @@ -98,11 +97,11 @@ - - @@ -111,44 +110,29 @@ { - - - - - - - - - } - else if (SelectedTab == Tabs.Personality) - { - - @WEB.Resources.GlobalTranslations.ProfilePreferPersonTip1 - - - - - - - - - - } } - *@ @@ -46,58 +41,53 @@ @code { [Parameter] public DateTime Value { get; set; } [Parameter] public EventCallback ValueChanged { get; set; } - - public EventCallback DayChanged { get; set; } - public EventCallback MonthChanged { get; set; } - public EventCallback YearChanged { get; set; } - [Parameter] public bool Required { get; set; } - private int day = DateTime.Now.Day; + private int year = DateTime.Now.Year; private int month = DateTime.Now.Month; - private int year = DateTime.Now.AddYears(-18).Year; + private int day = DateTime.Now.Day; + + private int[] years => Enumerable.Range(DateTime.Now.AddYears(-100).Year, 100).OrderDescending().ToArray(); + private int[] months => Enumerable.Range(1, 12).ToArray(); + private int[] days => Enumerable.Range(1, DateTime.DaysInMonth(year, month)).ToArray(); protected override void OnInitialized() { - day = Value.Day; - month = Value.Month; year = Value.Year; + month = Value.Month; + day = Value.Day; } - private async Task SetDay(int value) + private async Task SetYear(int value) { - try - { - day = value; - Value = new DateTime(year, month, day); - await ValueChanged.InvokeAsync(Value); - } - catch (Exception) - { - await Toast.Error("Ocorreu um erro ao processar a data"); - } + year = value; + await SetValue(); } private async Task SetMonth(int value) { - try - { - month = value; - Value = new DateTime(year, month, day); - await ValueChanged.InvokeAsync(Value); - } - catch (Exception) - { - await Toast.Error("Ocorreu um erro ao processar a data"); - } + month = value; + await SetValue(); } - private async Task SetYear(int value) + private async Task SetDay(int value) + { + day = value; + await SetValue(); + } + + private async Task SetValue() { try { - year = value; - Value = new DateTime(year, month, day); + var date = DateTime.Today; + + if (year != default && month != default && day != default) + { + date = new DateTime(year, month, day); + } + + Value = date; await ValueChanged.InvokeAsync(Value); } catch (Exception) diff --git a/MM.WEB/Modules/Shared/Field/FieldSelect.razor b/MM.WEB/Modules/Shared/Field/FieldSelect.razor index 88774bb..0df8e26 100644 --- a/MM.WEB/Modules/Shared/Field/FieldSelect.razor +++ b/MM.WEB/Modules/Shared/Field/FieldSelect.razor @@ -6,7 +6,7 @@ { - @For.GetCustomAttribute()?.Name + @For?.GetCustomAttribute()?.Name @if (Required) {
*
@@ -22,7 +22,8 @@ { @foreach (var item in SelectedValues) { - + @item.GetName() } diff --git a/MM.WEB/Modules/Shared/Field/FieldSelect.razor.cs b/MM.WEB/Modules/Shared/Field/FieldSelect.razor.cs index 97e4e99..e8550a7 100644 --- a/MM.WEB/Modules/Shared/Field/FieldSelect.razor.cs +++ b/MM.WEB/Modules/Shared/Field/FieldSelect.razor.cs @@ -24,16 +24,16 @@ public partial class FieldSelect : FormBase SelectedValueChanged { get; set; } - [Parameter] public IReadOnlyList? SelectedValues { get; set; } - [Parameter] public EventCallback> SelectedValuesChanged { get; set; } + [Parameter] public HashSet? SelectedValues { get; set; } + [Parameter] public EventCallback> SelectedValuesChanged { get; set; } - private string? Description => For.GetCustomAttribute()?.Description; + private string? Description => For?.GetCustomAttribute()?.Description; [Parameter] public Func Order { get; set; } = o => o.Value; - protected Task UpdateDataHelp(Expression> For) + protected Task UpdateDataHelp(Expression>? For) { - return ModalService.Show>(For.GetCustomAttribute()?.Name, + return ModalService.Show>(For?.GetCustomAttribute()?.Name, x => { x.Add(x => x.HasGroup, ShowGroup); @@ -46,7 +46,7 @@ protected Task UpdateDataHelp(Expression> For) }); } - protected Task UpdateDataSelect(Expression> For) + protected Task UpdateDataSelect(Expression>? For) { return ModalService.Show>("", x => @@ -55,7 +55,7 @@ protected Task UpdateDataSelect(Expression> For) x.Add(x => x.SelectedValues, SelectedValues); x.Add(x => x.SelectedValuesChanged, SelectedValuesChanged); x.Add(x => x.Order, Order); - x.Add(x => x.Title, For.GetCustomAttribute()?.Name); + x.Add(x => x.Title, For?.GetCustomAttribute()?.Name); }, new ModalInstanceOptions() { diff --git a/MM.WEB/Modules/Shared/Field/ProfileDataSelect.razor b/MM.WEB/Modules/Shared/Field/ProfileDataSelect.razor index c3e5dde..f8730fb 100644 --- a/MM.WEB/Modules/Shared/Field/ProfileDataSelect.razor +++ b/MM.WEB/Modules/Shared/Field/ProfileDataSelect.razor @@ -54,8 +54,8 @@ [Parameter] public bool HasGroup { get; set; } [Parameter] public Func Order { get; set; } = o => o.Value; - [Parameter] public IReadOnlyList SelectedValues { get; set; } = Array.Empty(); - [Parameter] public EventCallback> SelectedValuesChanged { get; set; } + [Parameter] public HashSet SelectedValues { get; set; } = []; + [Parameter] public EventCallback> SelectedValuesChanged { get; set; } [Parameter] public string? Title { get; set; } @@ -71,14 +71,14 @@ { if (value) //add { - if (SelectedValues == null) SelectedValues = Array.Empty(); - SelectedValues = SelectedValues.ToArray().Concat(new TEnum[] { (TEnum)item.Value }).ToList().AsReadOnly(); + if (SelectedValues == null) SelectedValues = []; + SelectedValues = SelectedValues.Concat(new TEnum[] { (TEnum)item.Value }).ToHashSet(); } else //remove { - var list = SelectedValues.ToList(); + var list = SelectedValues; list.Remove((TEnum)item.Value); - SelectedValues = list.AsReadOnly(); + SelectedValues = list; } } diff --git a/MM.WEB/Modules/Subscription/Components/SubscriptionPopup.razor b/MM.WEB/Modules/Subscription/Components/SubscriptionPopup.razor index 1479763..5abb15a 100644 --- a/MM.WEB/Modules/Subscription/Components/SubscriptionPopup.razor +++ b/MM.WEB/Modules/Subscription/Components/SubscriptionPopup.razor @@ -48,6 +48,12 @@ @AccountProduct.Basic.GetRestrictions().FavoriteProviders + + @Profile.Resources.Translations.MySuggestions + + @AccountProduct.Basic.GetRestrictions().MySuggestions + + Watched @@ -86,6 +92,12 @@ @AccountProduct.Standard.GetRestrictions().FavoriteProviders + + @Profile.Resources.Translations.MySuggestions + + @AccountProduct.Standard.GetRestrictions().MySuggestions + + Watched @@ -125,6 +137,12 @@ @AccountProduct.Premium.GetRestrictions().FavoriteProviders + + @Profile.Resources.Translations.MySuggestions + + @AccountProduct.Premium.GetRestrictions().MySuggestions + + Watched @@ -381,7 +399,7 @@ for (int i = 0; i < 20; i++) { - await Task.Delay(1000); + await Task.Delay(2000); var principal = await PrincipalApi.Get(IsAuthenticated, true); if (principal?.ClientePaddle != null && principal.ClientePaddle.SubscriptionId.NotEmpty()) diff --git a/MM.WEB/Modules/Support/Component/AnnouncementComponent.razor b/MM.WEB/Modules/Support/Component/AnnouncementComponent.razor index fc646a5..775047a 100644 --- a/MM.WEB/Modules/Support/Component/AnnouncementComponent.razor +++ b/MM.WEB/Modules/Support/Component/AnnouncementComponent.razor @@ -11,12 +11,6 @@ @item.Title - @if (item.IsNew) - { - - @WEB.Resources.Button.New - - } @@ -26,20 +20,11 @@
@code { - [Parameter] public HashSet Updates { get; set; } = []; - [Parameter] public RenderControlCore> Core { get; set; } = new(); + public HashSet Updates { get; set; } = []; + public RenderControlCore> Core { get; set; } = new(); - protected override async Task OnInitializedAsync() + protected override async Task LoadDataRender() { - await Task.Delay(2000).ContinueWith(async (task) => - { - await JsRuntime.InvokeAsync("SetLocalStorage", "updates-date", DateTime.Now.Ticks); - foreach (var item in Updates) - { - item.IsNew = false; - UpdateApi.DataChanged?.Invoke(item); - } - StateHasChanged(); - }); + Updates = await UpdateApi.Get(Core); } } diff --git a/MM.WEB/Modules/Support/Component/DownloadComponent.razor b/MM.WEB/Modules/Support/Component/DownloadComponent.razor index 43962d2..9e78a94 100644 --- a/MM.WEB/Modules/Support/Component/DownloadComponent.razor +++ b/MM.WEB/Modules/Support/Component/DownloadComponent.razor @@ -27,9 +27,9 @@ Quick Links
- + @Resources.Translations.LinkTerm - + @Resources.Translations.LinkPrivacy @@ -66,6 +66,6 @@ Downloads.Add(new Item() { name = "Website", logo_path = "logo/website-logo.png", link = "https://www.streamingdiscovery.com/" }); Downloads.Add(new Item() { name = "Google Play", logo_path = "logo/google-play.png", link = "https://play.google.com/store/apps/details?id=com.streamingdiscovery.www.twa" }); Downloads.Add(new Item() { name = "Microsoft Store", logo_path = "logo/microsoft-store.png", link = "https://apps.microsoft.com/store/detail/streaming-discovery/9PB1PKRDD8L0" }); - Downloads.Add(new Item() { name = "Amazon Appstore", logo_path = "logo/amazon-logo.png", link = "https://www.amazon.com/gp/product/B0CL3KXKD9" }); + // Downloads.Add(new Item() { name = "Amazon Appstore", logo_path = "logo/amazon-logo.png", link = "https://www.amazon.com/gp/product/B0CL3KXKD9" }); } } \ No newline at end of file diff --git a/MM.WEB/Modules/Support/Component/FeedbackComponent.razor b/MM.WEB/Modules/Support/Component/FeedbackComponent.razor index db24d62..7e2573c 100644 --- a/MM.WEB/Modules/Support/Component/FeedbackComponent.razor +++ b/MM.WEB/Modules/Support/Component/FeedbackComponent.razor @@ -1,8 +1,8 @@ @using MM.Shared.Models.Support; @using MM.WEB.Modules.Support.Core; + @inherits ComponentCore @inject TicketApi TicketApi -@inject TicketVoteApi TicketVoteApi @@ -77,11 +77,11 @@
- @item.TotalVotes -
@@ -142,7 +142,6 @@ public RenderControlCore> Core { get; set; } = new(); private HashSet tickets = new(); - private HashSet myVotes = new(); private TicketType TicketTypeSel { get; set; } = TicketType.Improvement; private TicketStatus? TicketStatusSel { get; set; } @@ -160,8 +159,6 @@ protected override async Task LoadDataRender() { tickets = await TicketApi.GetList(Core); - - myVotes = await TicketVoteApi.GetMyVotes(IsAuthenticated); } private List GetTicketList(TicketType ticketType, TicketStatus? ticketStatus, Order order) @@ -197,16 +194,11 @@ } else { - var vote = new TicketVoteModel(); - vote.Initialize("", IdTicket); - - vote.VoteType = voteType; - vote.IdVotedUser = UserId; + var ticket = tickets.Single(s => s.Id == IdTicket); - await TicketVoteApi.Vote(vote); - tickets.Single(s => s.Key == IdTicket.ToString()).Vote(voteType); + ticket.Vote(UserId!, voteType); - myVotes.Add(vote); + await TicketApi.Insert(ticket); await Toast.Success("Voto registrado com sucesso"); } @@ -217,5 +209,5 @@ } } - private bool anyVote(string? IdTicket, string? IdUser) => myVotes.Any(a => a.Key == IdTicket & a.IdVotedUser == IdUser); + private bool anyVote(string? IdTicket, string? IdUser) => tickets.Single(s => s.Id == IdTicket).Votes.Any(a => a.IdVotedUser == IdUser); } \ No newline at end of file diff --git a/MM.WEB/Modules/Support/Core/TicketVoteApi.cs b/MM.WEB/Modules/Support/Core/TicketVoteApi.cs deleted file mode 100644 index 3990895..0000000 --- a/MM.WEB/Modules/Support/Core/TicketVoteApi.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Microsoft.Extensions.Caching.Memory; -using MM.Shared.Models.Support; - -namespace MM.WEB.Modules.Support.Core -{ - public class TicketVoteApi(IHttpClientFactory http, IMemoryCache memoryCache) : ApiCosmos(http, memoryCache, "TicketVoteModel") - { - private struct Endpoint - { - public const string GetMyVotes = "Ticket/GetMyVotes"; - public const string Vote = "Ticket/Vote"; - } - - public async Task> GetMyVotes(bool IsUserAuthenticated) - { - if (IsUserAuthenticated) - { - return await GetListAsync(Endpoint.GetMyVotes, null, false); - } - else - { - return []; - } - } - - public async Task Vote(TicketVoteModel obj) - { - return await PostAsync(Endpoint.Vote, null, obj); - } - } -} \ No newline at end of file diff --git a/MM.WEB/Program.cs b/MM.WEB/Program.cs index 1ec1957..6a8aaa5 100644 --- a/MM.WEB/Program.cs +++ b/MM.WEB/Program.cs @@ -58,7 +58,6 @@ static void ConfigureServices(IServiceCollection collection, string baseAddress) collection.AddScoped(); collection.AddScoped(); collection.AddScoped(); - collection.AddScoped(); collection.AddScoped(); collection.AddScoped(); collection.AddScoped(); @@ -105,5 +104,5 @@ static IAsyncPolicy GetRetryPolicy() { return HttpPolicyExtensions .HandleTransientHttpError() // 408,5xx - .WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))); // Retry 2 times, with wait 1, 2 and 4 seconds. + .WaitAndRetryAsync(2, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))); // Retry 2 times, with wait 1, 2 and 4 seconds. } \ No newline at end of file diff --git a/MM.WEB/Resources/BuildDate.txt b/MM.WEB/Resources/BuildDate.txt index f8a7583..8dcd6df 100644 --- a/MM.WEB/Resources/BuildDate.txt +++ b/MM.WEB/Resources/BuildDate.txt @@ -1 +1 @@ -2024.04.07 +2024.07.13 diff --git a/MM.WEB/Resources/GlobalTranslations.Designer.cs b/MM.WEB/Resources/GlobalTranslations.Designer.cs index ab4969b..f37940c 100644 --- a/MM.WEB/Resources/GlobalTranslations.Designer.cs +++ b/MM.WEB/Resources/GlobalTranslations.Designer.cs @@ -60,6 +60,15 @@ internal GlobalTranslations() { } } + /// + /// Looks up a localized string similar to Active Connection. + /// + public static string ActiveConnection { + get { + return ResourceManager.GetString("ActiveConnection", resourceCulture); + } + } + /// /// Looks up a localized string similar to Beta Version!. /// @@ -70,7 +79,7 @@ public static string BetaVersion { } /// - /// Looks up a localized string similar to This information will not be shared on your profile (only your age). + /// Looks up a localized string similar to Only your age will be published. (We use the Gregorian calendar). /// public static string BirthdateTip { get { @@ -357,6 +366,15 @@ public static string PWAUpdaterText { } } + /// + /// Looks up a localized string similar to Settings. + /// + public static string Settings { + get { + return ResourceManager.GetString("Settings", resourceCulture); + } + } + /// /// Looks up a localized string similar to Share. /// diff --git a/MM.WEB/Resources/GlobalTranslations.es.resx b/MM.WEB/Resources/GlobalTranslations.es.resx index 662e3e0..ba23f8f 100644 --- a/MM.WEB/Resources/GlobalTranslations.es.resx +++ b/MM.WEB/Resources/GlobalTranslations.es.resx @@ -121,7 +121,7 @@ ¡Versión beta!
- Esta información no se compartirá en su perfil (solo su edad) + Sólo se publicará tu edad. (Usamos el calendario gregoriano) Operación no válida. Por favor, inténtelo de nuevo. @@ -243,4 +243,7 @@ Su ubicación actual: + + Conexión activa + \ No newline at end of file diff --git a/MM.WEB/Resources/GlobalTranslations.pt.resx b/MM.WEB/Resources/GlobalTranslations.pt.resx index efc159a..be6211f 100644 --- a/MM.WEB/Resources/GlobalTranslations.pt.resx +++ b/MM.WEB/Resources/GlobalTranslations.pt.resx @@ -121,7 +121,7 @@ Versão Beta! - Esta informação não será compartilhada no seu perfil (apenas na sua idade) + Apenas sua idade ficará publica. (Utilizamos o calendario gregoriano) Operação inválida. Por favor, tente novamente. @@ -243,4 +243,7 @@ Sua localização atual: + + Conexão ativa + \ No newline at end of file diff --git a/MM.WEB/Resources/GlobalTranslations.resx b/MM.WEB/Resources/GlobalTranslations.resx index 05a3381..30f0c42 100644 --- a/MM.WEB/Resources/GlobalTranslations.resx +++ b/MM.WEB/Resources/GlobalTranslations.resx @@ -121,7 +121,7 @@ Beta Version! - This information will not be shared on your profile (only your age) + Only your age will be published. (We use the Gregorian calendar) Invalid operation. Please try again. @@ -207,6 +207,9 @@ A new version is available + + Settings + Share @@ -243,4 +246,7 @@ This option will have explanations of each of the items available to choose from. + + Active Connection + \ No newline at end of file diff --git a/MM.WEB/Shared/HeadLayout.razor b/MM.WEB/Shared/HeadLayout.razor index 9ca096a..96ef5b9 100644 --- a/MM.WEB/Shared/HeadLayout.razor +++ b/MM.WEB/Shared/HeadLayout.razor @@ -7,28 +7,6 @@ - -
- - - - - - - - -
-
@@ -42,28 +20,21 @@ + @code { - private IReadOnlyList Regions { get; set; } = Array.Empty(); - private IReadOnlyList Languages { get; set; } = Array.Empty(); - - protected override void OnInitialized() - { - base.OnInitialized(); - - Languages = EnumHelper.GetObjArray().Where(w => !string.IsNullOrEmpty(w.Name) && w.Group == "Website").ToArray(); - } - private void Logout() { Navigation.NavigateTo("/.auth/logout", forceLoad: true); } - protected void LanguageValueChanged(Language value) + private async Task OpenConfigurations() { - Navigation.NavigateTo(Navigation.GetUriWithQueryParameter("language", value.ToString()), forceLoad: true); + await ModalService.SettingsPopup(); } } \ No newline at end of file diff --git a/MM.WEB/Shared/HeaderComponent.razor b/MM.WEB/Shared/HeaderComponent.razor new file mode 100644 index 0000000..f50ab2e --- /dev/null +++ b/MM.WEB/Shared/HeaderComponent.razor @@ -0,0 +1,33 @@ + + + + + @if (!string.IsNullOrEmpty(IconName)) + { + + } + @if (!string.IsNullOrEmpty(IconImage)) + { + + } + + @Title + + + + + @if (ChildContent != null) + { + @ChildContent + } + + + + +@code { + [Parameter] public string? IconName { get; set; } + [Parameter] public string? IconImage { get; set; } + [Parameter] public string? Title { get; set; } + + [Parameter] public RenderFragment? ChildContent { get; set; } +} diff --git a/MM.WEB/Shared/MainLayout.razor b/MM.WEB/Shared/MainLayout.razor index b9e0e50..dfb9c51 100644 --- a/MM.WEB/Shared/MainLayout.razor +++ b/MM.WEB/Shared/MainLayout.razor @@ -12,7 +12,6 @@ @inject INotificationService Toast @inject IJSRuntime JsRuntime @inject TicketApi TicketApi -@inject UpdateApi UpdateApi
@@ -33,7 +32,7 @@ @Body - @if (AppStateStatic.Language == Language.pt) + @if (AppStateStatic.Language == Language.Portuguese) { @@ -103,12 +102,6 @@ @MM.WEB.Modules.Support.Resources.Translations.Home @MM.WEB.Modules.Support.Resources.Translations.Updates - @if (Updates.Any(a => a.IsNew)) - { - - @Updates.Count(c => c.IsNew) - - } @MM.WEB.Modules.Support.Resources.Translations.Feedback @@ -117,10 +110,10 @@ - + - + @@ -130,9 +123,6 @@ @code { [CascadingParameter] protected Task authenticationState { get; set; } = default!; - public HashSet Updates { get; set; } = []; - public RenderControlCore> UpdateCore { get; set; } = new(); - public string? Tab { get; set; } = "Home"; public string GetMargin => "me-4 mb-lg-4 mb-6"; @@ -148,15 +138,6 @@ Navigation.LocationChanged += OnLocationChanged; AppStateStatic.ShowError = async (msg) => { await Toast.Error(msg); }; AppStateStatic.ShowFeedback = (show) => { ShowFeedback(show); }; - UpdateApi.DataChanged += (UpdateModel? model) => - { - var item = Updates.FirstOrDefault(f => f.Id == model?.Id); - if (item != null) - { - item = model; - } - StateHasChanged(); - }; ChangeCurrentButton(Navigation.Uri); @@ -165,40 +146,20 @@ protected bool IsAuthenticated { get; set; } = false; protected string? UserId { get; set; } + public ClaimsPrincipal? User { get; set; } protected override async Task OnInitializedAsync() { - if (authenticationState is not null) + if (User == null && authenticationState is not null) { var authState = await authenticationState; - var User = authState?.User; + User = authState?.User; IsAuthenticated = User?.Identity is not null && User.Identity.IsAuthenticated; UserId = User?.FindFirst(c => c.Type == ClaimTypes.NameIdentifier)?.Value; } } - protected override async Task OnAfterRenderAsync(bool firstRender) - { - Updates = await UpdateApi.Get(UpdateCore); - - try - { - var date = await JsRuntime.InvokeAsync("GetLocalStorage", "updates-date"); - foreach (var item in Updates) - { - if (date.NotEmpty() && long.Parse(date) > item.Date.Ticks) - { - item.IsNew = false; - } - } - } - catch (Exception ex) - { - ex.ProcessException(Toast, Logger); - } - } - private void OnLocationChanged(object? sender, LocationChangedEventArgs args) { ChangeCurrentButton(args.Location); diff --git a/MM.WEB/Shared/SettingsPopup.razor b/MM.WEB/Shared/SettingsPopup.razor new file mode 100644 index 0000000..bf3ac39 --- /dev/null +++ b/MM.WEB/Shared/SettingsPopup.razor @@ -0,0 +1,23 @@ +@using MM.WEB.Modules.Profile +@inherits ComponentCore + + + @GlobalTranslations.Settings + + + + + + + + + +@code { + protected void LanguageValueChanged(Language value) + { + Navigation.NavigateTo(Navigation.GetUriWithQueryParameter("language", value.GetName(false)), forceLoad: true); + } +} diff --git a/MM.WEB/_Imports.razor b/MM.WEB/_Imports.razor index 2b1a387..edfcc21 100644 --- a/MM.WEB/_Imports.razor +++ b/MM.WEB/_Imports.razor @@ -18,7 +18,6 @@ @using MM.Shared.Core @using MM.Shared.Core.Helper -@using MM.Shared.Enums @using MM.Shared.Models @using MM.WEB.Core diff --git a/MM.WEB/wwwroot/appsettings.json b/MM.WEB/wwwroot/appsettings.json index d9adb92..0e0dcd2 100644 --- a/MM.WEB/wwwroot/appsettings.json +++ b/MM.WEB/wwwroot/appsettings.json @@ -1,3 +1,3 @@ { - //"BlobPath": "https://storageverusdate.blob.core.windows.net/" + } \ No newline at end of file diff --git a/MM.WEB/wwwroot/css/custom_app.css b/MM.WEB/wwwroot/css/custom_app.css index 5fa2f89..776a8eb 100644 --- a/MM.WEB/wwwroot/css/custom_app.css +++ b/MM.WEB/wwwroot/css/custom_app.css @@ -55,7 +55,9 @@ } .modal-header { - padding: 0.5rem !important; + padding-top: 0.5rem !important; + padding-bottom: 0.5rem !important; + padding-left: 0.5rem !important; } .modal-body { diff --git a/MM.WEB/wwwroot/css/custom_app.min.css b/MM.WEB/wwwroot/css/custom_app.min.css index 81c9634..ad81554 100644 --- a/MM.WEB/wwwroot/css/custom_app.min.css +++ b/MM.WEB/wwwroot/css/custom_app.min.css @@ -1 +1 @@ -::-webkit-scrollbar{width:8px}::-webkit-scrollbar-track{background:#f1f1f1}::-webkit-scrollbar-thumb{background:#888}::-webkit-scrollbar-thumb:hover{background:#555}.b-layout-sider-content{z-index:4!important}.b-layout-header-fixed{z-index:3!important}.b-layout-footer{z-index:3!important}.figure{text-align:center}.figure-img{max-height:100%!important}.card-header{padding:.5rem!important}.card-body{padding:.5rem!important}.card-footer{padding:.5rem!important}.modal-header{padding:.5rem!important}.modal-body{padding:.5rem!important;max-height:80vh;overflow-y:auto;overflow-x:hidden}.modal-footer{padding:.5rem!important}.alert{padding:.5rem!important;margin-bottom:.5rem!important}.alert-warning{border-color:#efe696}body .pwa-updater[b-pwa-updater]{--pwa-updater-bar-backcolor:#228b22}dl,ol,ul{margin-top:0!important;margin-bottom:0!important}p{margin-top:0!important;margin-bottom:0!important}canvas{width:100%;max-width:100%;height:100%}.m-6{margin:4rem!important}.mt-6,.my-6{margin-top:4rem!important}.me-6,.mx-6{margin-right:4rem!important}.mb-6,.my-6{margin-bottom:4rem!important}.ms-6,.mx-6{margin-left:4rem!important} \ No newline at end of file +::-webkit-scrollbar{width:8px}::-webkit-scrollbar-track{background:#f1f1f1}::-webkit-scrollbar-thumb{background:#888}::-webkit-scrollbar-thumb:hover{background:#555}.b-layout-sider-content{z-index:4!important}.b-layout-header-fixed{z-index:3!important}.b-layout-footer{z-index:3!important}.figure{text-align:center}.figure-img{max-height:100%!important}.card-header{padding:.5rem!important}.card-body{padding:.5rem!important}.card-footer{padding:.5rem!important}.modal-header{padding-top:.5rem!important;padding-bottom:.5rem!important;padding-left:.5rem!important}.modal-body{padding:.5rem!important;max-height:80vh;overflow-y:auto;overflow-x:hidden}.modal-footer{padding:.5rem!important}.alert{padding:.5rem!important;margin-bottom:.5rem!important}.alert-warning{border-color:#efe696}body .pwa-updater[b-pwa-updater]{--pwa-updater-bar-backcolor:#228b22}dl,ol,ul{margin-top:0!important;margin-bottom:0!important}p{margin-top:0!important;margin-bottom:0!important}canvas{width:100%;max-width:100%;height:100%}.m-6{margin:4rem!important}.mt-6,.my-6{margin-top:4rem!important}.me-6,.mx-6{margin-right:4rem!important}.mb-6,.my-6{margin-bottom:4rem!important}.ms-6,.mx-6{margin-left:4rem!important} \ No newline at end of file diff --git a/MM.WEB/wwwroot/dev-env/me.json b/MM.WEB/wwwroot/dev-env/me.json index ed6e57a..8f087e0 100644 --- a/MM.WEB/wwwroot/dev-env/me.json +++ b/MM.WEB/wwwroot/dev-env/me.json @@ -2,7 +2,7 @@ "clientPrincipal": { "identityProvider": "google", "userId": "b9a10c8be2f244c0a625b78f05e30812", - "userDetails": "dhiogo@localhost.com", + "userDetails": "dhiogoacioli@gmail.com", "userRoles": [ "authenticated", "administrator" diff --git a/MM.WEB/wwwroot/index.html b/MM.WEB/wwwroot/index.html index 644c3a4..bb737cf 100644 --- a/MM.WEB/wwwroot/index.html +++ b/MM.WEB/wwwroot/index.html @@ -20,7 +20,7 @@ - + @@ -46,6 +46,7 @@ +