-
Notifications
You must be signed in to change notification settings - Fork 2
VCST-4174: Add optional container attribute #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 7 commits
df50532
925fe7f
be8fd12
00b9198
efa8e58
4a0d20b
e6f81ce
6d22f21
c535965
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| using System; | ||
|
|
||
| namespace VirtoCommerce.Xapi.Core.Models; | ||
|
|
||
| [AttributeUsage(AttributeTargets.Class)] | ||
| public class OptionalGraphQlTypesContainerAttribute : Attribute | ||
| { | ||
| public string DependencyName { get; set; } | ||
|
|
||
| public OptionalGraphQlTypesContainerAttribute(string dependencyName) | ||
| { | ||
| DependencyName = dependencyName; | ||
| } | ||
ksavosteev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,14 +67,15 @@ public async Task<StoreResponse> Handle(GetStoreQuery request, CancellationToken | |
| return null; | ||
| } | ||
|
|
||
| var cultureName = request.CultureName ?? store.DefaultLanguage; | ||
| var availableLanguages = !store.Languages.IsNullOrEmpty() ? store.Languages.Select(x => new Language(x)).ToList() : []; | ||
|
|
||
| var cultureName = GetCultureName(request.CultureName, store.DefaultLanguage, availableLanguages); | ||
|
|
||
| var allCurrencies = await _storeCurrencyResolver.GetAllStoreCurrenciesAsync(store.Id, cultureName); | ||
| var availableCurrencies = allCurrencies.Where(x => store.Currencies.Contains(x.Code)).ToList(); | ||
| var defaultCurrency = await _storeCurrencyResolver.GetStoreCurrencyAsync(store.DefaultCurrency, store.Id, cultureName); | ||
|
|
||
| var defaultLanguage = store.DefaultLanguage != null ? new Language(store.DefaultLanguage) : Language.InvariantLanguage; | ||
| var availableLanguages = !store.Languages.IsNullOrEmpty() ? store.Languages.Select(x => new Language(x)).ToList() : new List<Language>(); | ||
|
|
||
| var response = new StoreResponse | ||
| { | ||
|
|
@@ -197,4 +198,19 @@ protected virtual object ToSettingValue(ObjectSettingEntry s) | |
| return result; | ||
| } | ||
| } | ||
|
|
||
| private static string GetCultureName(string cultureName, string defaultCultureName, IList<Language> availableLanguages) | ||
| { | ||
| if (cultureName.IsNullOrEmpty()) | ||
| { | ||
| cultureName = defaultCultureName; | ||
| } | ||
| else if (cultureName.Length == 2) | ||
| { | ||
| cultureName = availableLanguages.FirstOrDefault(x => cultureName == x.TwoLetterLanguageName)?.CultureName; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Case-sensitive culture name comparison breaks lookupThe culture name lookup compares |
||
| cultureName ??= defaultCultureName; | ||
| } | ||
|
|
||
| return cultureName; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.