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
Privacy preference - Move with IFormCollection to IDictionary
supportc33198fc9345
diff --git a/src/Web/Grand.Web/Controllers/CommonController.cs b/src/Web/Grand.Web/Controllers/CommonController.csindex 0082330b5..5e6833f84 100644--- a/src/Web/Grand.Web/Controllers/CommonController.cs+++ b/src/Web/Grand.Web/Controllers/CommonController.cs@@ -477,25 +477,25 @@ namespace Grand.Web.Controllers[ClosedStore(true)][PublicStore(true)][DenySystemAccount]- public virtual async Task<IActionResult> PrivacyPreference(IFormCollection form,+ public virtual async Task<IActionResult> PrivacyPreference(IDictionary<string, string> model,[FromServices] StoreInformationSettings storeInformationSettings,[FromServices] IUserFieldService userFieldService,- [FromServices] ICookiePreference _cookiePreference)+ [FromServices] ICookiePreference cookiePreference){if (!storeInformationSettings.DisplayPrivacyPreference)return Json(new { success = false });- var consent = "ConsentCookies";+ const string consent = "ConsentCookies";await userFieldService.SaveField(_workContext.CurrentCustomer, SystemCustomerFieldNames.ConsentCookies, "", _workContext.CurrentStore.Id);var selectedConsentCookies = new List<string>();- foreach (var item in form)+ foreach (var item in model){if (item.Key.StartsWith(consent))selectedConsentCookies.Add(item.Value);}var dictionary = new Dictionary<string, bool>();- var consentCookies = _cookiePreference.GetConsentCookies();+ var consentCookies = cookiePreference.GetConsentCookies();foreach (var item in consentCookies){if (item.AllowToDisable)diff --git a/src/Web/Grand.Web/Views/Common/PrivacyPreference.cshtml b/src/Web/Grand.Web/Views/Common/PrivacyPreference.cshtmlindex d9515d9fa..c120a7006 100644--- a/src/Web/Grand.Web/Views/Common/PrivacyPreference.cshtml+++ b/src/Web/Grand.Web/Views/Common/PrivacyPreference.cshtml@@ -15,7 +15,7 @@<div>@item.Description</div></div><div class="custom-control custom-switch">- <input @if (!(item.AllowToDisable)) { <text> disabled checked</text> } @if (item.State == true) { <text> checked</text> } type="checkbox"+ <input @if (!(item.AllowToDisable)) { <text> checked</text> } @if (item.State == true) { <text> checked</text> } type="checkbox"value="@item.SystemName" class="custom-control-input" id="[email protected]" name="[email protected]"><label class="custom-control-label" for="[email protected]"></label></div>