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
Remove Ask Question from the project #181
KrzysztofPajak71257257b9a6
diff --git a/src/Business/Grand.Business.System/Services/Installation/InstallDataSettings.cs b/src/Business/Grand.Business.System/Services/Installation/InstallDataSettings.csindex fefda6188..2e7d8bc9f 100644--- a/src/Business/Grand.Business.System/Services/Installation/InstallDataSettings.cs+++ b/src/Business/Grand.Business.System/Services/Installation/InstallDataSettings.cs@@ -203,7 +203,6 @@ namespace Grand.Business.System.Services.InstallationProductReviewPossibleOnlyOnce = false,NotifyStoreOwnerAboutNewProductReviews = false,EmailAFriendEnabled = true,- AskQuestionEnabled = false,AskQuestionOnProduct = true,AllowAnonymousUsersToEmailAFriend = false,RecentlyViewedProductsNumber = 3,diff --git a/src/Core/Grand.Domain/Catalog/CatalogSettings.cs b/src/Core/Grand.Domain/Catalog/CatalogSettings.csindex e519e0200..a97cd5547 100644--- a/src/Core/Grand.Domain/Catalog/CatalogSettings.cs+++ b/src/Core/Grand.Domain/Catalog/CatalogSettings.cs@@ -135,11 +135,6 @@ namespace Grand.Domain.Catalog/// </summary>public bool EmailAFriendEnabled { get; set; }- /// <summary>- /// Gets or sets a value indicating whether 'ask product question' feature is enabled- /// </summary>- public bool AskQuestionEnabled { get; set; }-/// <summary>/// Gets or sets a value indicating whether 'contact us on the product page' feature is enabled/// </summary>diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Catalog.TabGeneralSettings.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Catalog.TabGeneralSettings.cshtmlindex 75f708b14..5b3601784 100644--- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Catalog.TabGeneralSettings.cshtml+++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Catalog.TabGeneralSettings.cshtml@@ -275,18 +275,6 @@<span asp-validation-for="CategoryBreadcrumbEnabled"></span></div></div>- <div class="form-group">- <div class="col-6 col-md-6 col-sm-6">- <admin-label asp-for="AskQuestionEnabled" class="control-label" />- </div>- <div class="col-6 col-md-6 col-sm-6">- <label class="mt-checkbox mt-checkbox-outline control control-checkbox">- <admin-input asp-for="AskQuestionEnabled" />- <div class="control__indicator"></div>- </label>- <span asp-validation-for="AskQuestionEnabled"></span>- </div>- </div><div class="form-group"><div class="col-6 col-md-6 col-sm-6"><admin-label asp-for="AskQuestionOnProduct" class="control-label" />diff --git a/src/Web/Grand.Web.Admin/Models/Settings/CatalogSettingsModel.cs b/src/Web/Grand.Web.Admin/Models/Settings/CatalogSettingsModel.csindex fb7100c70..539b33e81 100644--- a/src/Web/Grand.Web.Admin/Models/Settings/CatalogSettingsModel.cs+++ b/src/Web/Grand.Web.Admin/Models/Settings/CatalogSettingsModel.cs@@ -81,9 +81,6 @@ namespace Grand.Web.Admin.Models.Settings[GrandResourceDisplayName("Admin.Settings.Catalog.EmailAFriendEnabled")]public bool EmailAFriendEnabled { get; set; }- [GrandResourceDisplayName("Admin.Settings.Catalog.AskQuestionEnabled")]- public bool AskQuestionEnabled { get; set; }-[GrandResourceDisplayName("Admin.Settings.Catalog.AskQuestionOnProduct")]public bool AskQuestionOnProduct { get; set; }diff --git a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xmlindex dfc253b04..b562ddc3b 100644--- a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml+++ b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml@@ -10594,9 +10594,6 @@<Resource Name="Admin.Settings.Catalog.AllowViewUnpublishedProductPage"><Value>Allow viewing of unpublished product details page</Value></Resource>- <Resource Name="Admin.Settings.Catalog.AskQuestionEnabled">- <Value>'Ask question' enabled</Value>- </Resource><Resource Name="Admin.Settings.Catalog.AskQuestionOnProduct"><Value>'Ask question on the product page' enabled</Value></Resource>diff --git a/src/Web/Grand.Web/Controllers/ProductController.cs b/src/Web/Grand.Web/Controllers/ProductController.csindex 46dcad12c..5c06e0bb4 100644--- a/src/Web/Grand.Web/Controllers/ProductController.cs+++ b/src/Web/Grand.Web/Controllers/ProductController.cs@@ -719,70 +719,6 @@ namespace Grand.Web.Controllers#region Ask question- public virtual async Task<IActionResult> AskQuestion(string productId)- {- var product = await _productService.GetProductById(productId);- if (product == null || !product.Published || !_catalogSettings.AskQuestionEnabled)- return NotFound();-- var model = await _mediator.Send(new GetProductAskQuestion() {- Product = product,- Customer = _workContext.CurrentCustomer,- Language = _workContext.WorkingLanguage,- Store = _workContext.CurrentStore- });-- return View(model);- }-- [HttpPost]- [AutoValidateAntiforgeryToken]- [ValidateCaptcha]- public virtual async Task<IActionResult> AskQuestion(ProductAskQuestionModel model, bool captchaValid)- {- var product = await _productService.GetProductById(model.ProductId);- if (product == null || !product.Published || !_catalogSettings.AskQuestionEnabled)- return NotFound();-- // validate CAPTCHA- if (_captchaSettings.Enabled && _captchaSettings.ShowOnAskQuestionPage && !captchaValid)- {- ModelState.AddModelError("", _captchaSettings.GetWrongCaptchaMessage(_translationService));- }-- if (ModelState.IsValid)- {- await _mediator.Send(new SendProductAskQuestionMessageCommand() {- Customer = _workContext.CurrentCustomer,- Language = _workContext.WorkingLanguage,- Store = _workContext.CurrentStore,- Model = model,- Product = product,- RemoteIpAddress = HttpContext.Connection?.RemoteIpAddress?.ToString()- });-- //activity log- _ = _customerActivityService.InsertActivity("PublicStore.AskQuestion", _workContext.CurrentCustomer.Id,- _workContext.CurrentCustomer, HttpContext.Connection?.RemoteIpAddress?.ToString(),- _translationService.GetResource("ActivityLog.PublicStore.AskQuestion"));-- model.SuccessfullySent = true;- model.ProductSeName = product.GetSeName(_workContext.WorkingLanguage.Id);- model.ProductName = product.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id);- model.Result = _translationService.GetResource("Products.AskQuestion.SuccessfullySent");- return View(model);- }-- // If we got this far, something failed, redisplay form- var customer = _workContext.CurrentCustomer;- model.Id = product.Id;- model.ProductName = product.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id);- model.ProductSeName = product.GetSeName(_workContext.WorkingLanguage.Id);- model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnAskQuestionPage;- return View(model);- }-[HttpPost][AutoValidateAntiforgeryToken][ValidateCaptcha]diff --git a/src/Web/Grand.Web/Endpoints/EndpointProvider.cs b/src/Web/Grand.Web/Endpoints/EndpointProvider.csindex 895480597..b9f3af6dc 100644--- a/src/Web/Grand.Web/Endpoints/EndpointProvider.cs+++ b/src/Web/Grand.Web/Endpoints/EndpointProvider.cs@@ -288,12 +288,7 @@ namespace Grand.Web.EndpointsendpointRouteBuilder.MapControllerRoute("ProductEmailAFriend",pattern + "productemailafriend/{productId?}",new { controller = "Product", action = "ProductEmailAFriend" });-- //product ask question- endpointRouteBuilder.MapControllerRoute("AskQuestion",- pattern + "askquestion/{productId}",- new { controller = "Product", action = "AskQuestion" });-+//product ask question on product pageendpointRouteBuilder.MapControllerRoute("AskQuestionOnProduct",pattern + "askquestiononproduct",diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductAskQuestionHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductAskQuestionHandler.csdeleted file mode 100644index d3865bed0..000000000--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductAskQuestionHandler.cs+++ /dev/null@@ -1,37 +0,0 @@-using Grand.Business.Common.Extensions;-using Grand.Domain.Common;-using Grand.Domain.Customers;-using Grand.Web.Common.Security.Captcha;-using Grand.Web.Features.Models.Products;-using Grand.Web.Models.Catalog;-using MediatR;-using System.Threading;-using System.Threading.Tasks;--namespace Grand.Web.Features.Handlers.Products-{- public class GetProductAskQuestionHandler : IRequestHandler<GetProductAskQuestion, ProductAskQuestionModel>- {- private readonly CaptchaSettings _captchaSettings;-- public GetProductAskQuestionHandler(CaptchaSettings captchaSettings)- {- _captchaSettings = captchaSettings;- }-- public async Task<ProductAskQuestionModel> Handle(GetProductAskQuestion request, CancellationToken cancellationToken)- {- var model = new ProductAskQuestionModel();- model.Id = request.Product.Id;- model.ProductName = request.Product.GetTranslation(x => x.Name, request.Language.Id);- model.ProductSeName = request.Product.GetSeName(request.Language.Id);- model.Email = request.Customer.Email;- model.FullName = request.Customer.GetFullName();- model.Phone = request.Customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.Phone);- model.Message = "";- model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnAskQuestionPage;-- return await Task.FromResult(model);- }- }-}diff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.csindex 769fe9cc4..8a1a0418d 100644--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsPageHandler.cs@@ -392,7 +392,6 @@ namespace Grand.Web.Features.Handlers.ProductsAdditionalShippingCharge = product.AdditionalShippingCharge,NotReturnable = product.NotReturnable,EmailAFriendEnabled = _catalogSettings.EmailAFriendEnabled,- AskQuestionEnabled = _catalogSettings.AskQuestionEnabled,AskQuestionOnProduct = _catalogSettings.AskQuestionOnProduct,RenderCaptcha = _captchaSettings.Enabled && (_captchaSettings.ShowOnEmailProductToFriendPage|| _captchaSettings.ShowOnProductReviewPagediff --git a/src/Web/Grand.Web/Features/Models/Products/GetProductAskQuestion.cs b/src/Web/Grand.Web/Features/Models/Products/GetProductAskQuestion.csdeleted file mode 100644index 7ab94a3dd..000000000--- a/src/Web/Grand.Web/Features/Models/Products/GetProductAskQuestion.cs+++ /dev/null@@ -1,17 +0,0 @@-using Grand.Domain.Catalog;-using Grand.Domain.Customers;-using Grand.Domain.Localization;-using Grand.Domain.Stores;-using Grand.Web.Models.Catalog;-using MediatR;--namespace Grand.Web.Features.Models.Products-{- public class GetProductAskQuestion : IRequest<ProductAskQuestionModel>- {- public Product Product { get; set; }- public Language Language { get; set; }- public Store Store { get; set; }- public Customer Customer { get; set; }- }-}diff --git a/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs b/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.csindex 9637e8a66..658050457 100644--- a/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs+++ b/src/Web/Grand.Web/Models/Catalog/ProductDetailsModel.cs@@ -78,7 +78,6 @@ namespace Grand.Web.Models.Catalogpublic string StockAvailability { get; set; }public bool DisplayOutOfStockSubscription { get; set; }public bool EmailAFriendEnabled { get; set; }- public bool AskQuestionEnabled { get; set; }public bool AskQuestionOnProduct { get; set; }public ProductAskQuestionSimpleModel ProductAskQuestion { get; set; }public bool CompareProductsEnabled { get; set; }diff --git a/src/Web/Grand.Web/Views/Product/ProductLayout.Grouped.cshtml b/src/Web/Grand.Web/Views/Product/ProductLayout.Grouped.cshtmlindex 61191c001..8c34faee1 100644--- a/src/Web/Grand.Web/Views/Product/ProductLayout.Grouped.cshtml+++ b/src/Web/Grand.Web/Views/Product/ProductLayout.Grouped.cshtml@@ -98,7 +98,6 @@@await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_inside_overview_buttons_before", additionalData = Model.Id })<partial name="_ProductsComparison" model="Model" /><partial name="_SendFriend" model="Model" />- <partial name="_ProductAskQuestionButton" model="Model" />@await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_inside_overview_buttons_after", additionalData = Model.Id })</b-btn-group><partial name="_ShareButton" model="Model" />diff --git a/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml b/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtmlindex 2bae73cbe..dfaf5a0a9 100644--- a/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml+++ b/src/Web/Grand.Web/Views/Product/ProductLayout.Simple.cshtml@@ -181,10 +181,6 @@{<partial name="_SendFriend" model="Model" />}- @if (Model.AskQuestionEnabled)- {- <partial name="_ProductAskQuestionButton" model="Model" />- }</div></div></div>diff --git a/src/Web/Grand.Web/Views/Product/_ProductAskQuestionButton.cshtml b/src/Web/Grand.Web/Views/Product/_ProductAskQuestionButton.cshtmldeleted file mode 100644index b1ab8b89d..000000000--- a/src/Web/Grand.Web/Views/Product/_ProductAskQuestionButton.cshtml+++ /dev/null@@ -1,8 +0,0 @@-@model ProductDetailsModel-@if (Model.AskQuestionEnabled)-{- <a value="@Loc["Products.AskQuestion"]" class="btn btn-secondary ask-a-question-button mr-1" href="@Url.RouteUrl("AskQuestion", new { productId = Model.Id })" v-b-tooltip.hover.bottom title="@Loc["Products.AskQuestion"]">- <b-icon icon="question-circle"></b-icon>- <span class="sr-only">@Loc["Products.AskQuestion"]</span>- </a>-}\ No newline at end of file