Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Minor changes CountryService
support917b1754280b
diff --git a/src/Business/Grand.Business.Common/Services/Directory/CountryService.cs b/src/Business/Grand.Business.Common/Services/Directory/CountryService.csindex 192ea72c9..7a2d32d73 100644--- a/src/Business/Grand.Business.Common/Services/Directory/CountryService.cs+++ b/src/Business/Grand.Business.Common/Services/Directory/CountryService.cs@@ -54,7 +54,7 @@ namespace Grand.Business.Common.Services.Directory/// <returns>Countries</returns>public virtual async Task<IList<Country>> GetAllCountries(string languageId = "", string storeId = "", bool showHidden = false){- string key = string.Format(CacheKey.COUNTRIES_ALL_KEY, languageId, showHidden);+ string key = string.Format(CacheKey.COUNTRIES_ALL_KEY, languageId, storeId, showHidden);return await _cacheBase.GetAsync(key, async () =>{@@ -235,9 +235,8 @@ namespace Grand.Business.Common.Services.Directory/// </summary>/// <param name="countryId">Country identifier</param>/// <param name="languageId">Language identifier.</param>- /// <param name="showHidden">A value indicating whether to show hidden records</param>/// <returns>States</returns>- public virtual async Task<IList<StateProvince>> GetStateProvincesByCountryId(string countryId, string languageId = "", bool showHidden = false)+ public virtual async Task<IList<StateProvince>> GetStateProvincesByCountryId(string countryId, string languageId = ""){if (string.IsNullOrEmpty(countryId))return new List<StateProvince>();@@ -307,7 +306,8 @@ namespace Grand.Business.Common.Services.Directoryif (country == null)throw new ArgumentNullException(nameof(country));- country.StateProvinces.Remove(stateProvince);+ var state = country.StateProvinces.FirstOrDefault(x => x.Id == stateProvince.Id);+ country.StateProvinces.Remove(state);await UpdateCountry(country);diff --git a/src/Business/Grand.Business.Core/Interfaces/Common/Directory/ICountryService.cs b/src/Business/Grand.Business.Core/Interfaces/Common/Directory/ICountryService.csindex 0d14002ff..8696b48e1 100644--- a/src/Business/Grand.Business.Core/Interfaces/Common/Directory/ICountryService.cs+++ b/src/Business/Grand.Business.Core/Interfaces/Common/Directory/ICountryService.cs@@ -86,9 +86,8 @@ namespace Grand.Business.Core.Interfaces.Common.Directory/// </summary>/// <param name="countryId">Country identifier</param>/// <param name="languageId">Language identifier.</param>- /// <param name="showHidden">A value indicating whether to show hidden records</param>/// <returns>States</returns>- Task<IList<StateProvince>> GetStateProvincesByCountryId(string countryId, string languageId = "", bool showHidden = false);+ Task<IList<StateProvince>> GetStateProvincesByCountryId(string countryId, string languageId = "");/// <summary>/// Inserts a state/provincediff --git a/src/Core/Grand.Infrastructure/Caching/Constants/DirectoryCacheKey.cs b/src/Core/Grand.Infrastructure/Caching/Constants/DirectoryCacheKey.csindex 32a0a3831..bd3aff236 100644--- a/src/Core/Grand.Infrastructure/Caching/Constants/DirectoryCacheKey.cs+++ b/src/Core/Grand.Infrastructure/Caching/Constants/DirectoryCacheKey.cs@@ -117,9 +117,10 @@/// </summary>/// <remarks>/// {0} : language ID- /// {1} : show hidden records?+ /// {1} : store ID+ /// {2} : show hidden records?/// </remarks>- public static string COUNTRIES_ALL_KEY => "Grand.country.all-{0}-{1}";+ public static string COUNTRIES_ALL_KEY => "Grand.country.all-{0}-{1}-{2}";/// <summary>/// key for caching by country iddiff --git a/src/Plugins/Shipping.ByWeight/Areas/Admin/Controllers/ShippingByWeightController.cs b/src/Plugins/Shipping.ByWeight/Areas/Admin/Controllers/ShippingByWeightController.csindex 4e79c1079..40f8a3758 100644--- a/src/Plugins/Shipping.ByWeight/Areas/Admin/Controllers/ShippingByWeightController.cs+++ b/src/Plugins/Shipping.ByWeight/Areas/Admin/Controllers/ShippingByWeightController.cs@@ -280,7 +280,7 @@ namespace Shipping.ByWeight.Controllersforeach (var c in countries)model.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id.ToString(), Selected = (selectedCountry != null && c.Id == selectedCountry.Id) });//states- var states = selectedCountry != null ? await _countryService.GetStateProvincesByCountryId(selectedCountry.Id, showHidden: true) : new List<StateProvince>();+ var states = selectedCountry != null ? await _countryService.GetStateProvincesByCountryId(selectedCountry.Id) : new List<StateProvince>();model.AvailableStates.Add(new SelectListItem { Text = "*", Value = "" });foreach (var s in states)model.AvailableStates.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString(), Selected = (selectedState != null && s.Id == selectedState.Id) });