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
Add new component VendorContact
KrzysztofPajak807ce5802ee0
diff --git a/src/Web/Grand.Web/Components/VendorContact.cs b/src/Web/Grand.Web/Components/VendorContact.csnew file mode 100644index 000000000..3957ab072--- /dev/null+++ b/src/Web/Grand.Web/Components/VendorContact.cs@@ -0,0 +1,70 @@+using Grand.Business.Common.Extensions;+using Grand.Business.Customers.Interfaces;+using Grand.Domain.Common;+using Grand.Domain.Customers;+using Grand.Domain.Vendors;+using Grand.Infrastructure;+using Grand.Web.Common.Components;+using Grand.Web.Common.Security.Captcha;+using Grand.Web.Models.Common;+using Microsoft.AspNetCore.Mvc;+using System.Threading.Tasks;++namespace Grand.Web.Components+{+ public class VendorContactViewComponent : BaseViewComponent+ {+ #region Fields+ private readonly IVendorService _vendorService;+ private readonly IWorkContext _workContext;+ private readonly VendorSettings _vendorSettings;+ private readonly CommonSettings _commonSettings;+ private readonly CaptchaSettings _captchaSettings;+ #endregion++ #region Constructors++ public VendorContactViewComponent(+ IVendorService vendorService,+ IWorkContext workContext,+ VendorSettings vendorSettings,+ CommonSettings commonSettings,+ CaptchaSettings captchaSettings)+ {+ _vendorService = vendorService;+ _workContext = workContext;+ _vendorSettings = vendorSettings;+ _commonSettings = commonSettings;+ _captchaSettings = captchaSettings;+ }++ #endregion++ #region Invoker++ public async Task<IViewComponentResult> InvokeAsync(string vendorId)+ {+ if (!_vendorSettings.AllowCustomersToContactVendors)+ return Content("");++ var vendor = await _vendorService.GetVendorById(vendorId);+ if (vendor == null || !vendor.Active || vendor.Deleted)+ return Content("");++ var model = new ContactVendorModel {+ Email = _workContext.CurrentCustomer.Email,+ FullName = _workContext.CurrentCustomer.GetFullName(),+ SubjectEnabled = _commonSettings.SubjectFieldOnContactUsForm,+ DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnContactUsPage,+ VendorId = vendor.Id,+ VendorName = vendor.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id)+ };++ return View(model);++ }++ #endregion++ }+}