From 074c70e1cb9315c50b0afb5eeaaa6dc5a64dcb73 Mon Sep 17 00:00:00 2001 From: support Date: Thu, 16 Nov 2023 18:37:15 +0100 Subject: [PATCH] Remove vendor info section from Account details section --- .../Grand.Domain/Vendors/VendorSettings.cs | 5 - .../Areas/Admin/Views/Setting/Vendor.cshtml | 14 +- .../Models/Settings/VendorSettingsModel.cs | 2 - .../App_Data/Resources/DefaultLanguage.xml | 3 - .../Grand.Web/Controllers/VendorController.cs | 161 +--------------- .../Customers/GetNavigationHandler.cs | 4 - .../Customer/CustomerNavigationModel.cs | 1 - .../Models/Vendors/ApplyVendorModel.cs | 1 - .../Models/Vendors/VendorInfoModel.cs | 27 --- .../Validators/Vendors/VendorInfoValidator.cs | 25 --- .../CustomerNavigation/Default.cshtml | 180 ++++++++---------- .../Grand.Web/Views/Vendor/ApplyVendor.cshtml | 9 - src/Web/Grand.Web/Views/Vendor/Info.cshtml | 86 --------- 13 files changed, 82 insertions(+), 436 deletions(-) delete mode 100644 src/Web/Grand.Web/Models/Vendors/VendorInfoModel.cs delete mode 100644 src/Web/Grand.Web/Validators/Vendors/VendorInfoValidator.cs delete mode 100644 src/Web/Grand.Web/Views/Vendor/Info.cshtml diff --git a/src/Core/Grand.Domain/Vendors/VendorSettings.cs b/src/Core/Grand.Domain/Vendors/VendorSettings.cs index e0278161f..6e692d72b 100644 --- a/src/Core/Grand.Domain/Vendors/VendorSettings.cs +++ b/src/Core/Grand.Domain/Vendors/VendorSettings.cs @@ -45,11 +45,6 @@ public class VendorSettings : ISettings /// Get or sets a value indicating whether vendor can edit information about itself (public store) /// public bool AllowVendorsToEditInfo { get; set; } - /// - /// Get or sets a value indicating whether vendor can upload picture file - /// - public bool AllowToUploadFile { get; set; } - /// /// Gets or sets a value indicating whether the store owner is notified that the vendor information has been changed /// diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Vendor.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Vendor.cshtml index 71d5a9886..3acecf4b3 100644 --- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Vendor.cshtml +++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Setting/Vendor.cshtml @@ -209,19 +209,7 @@ -
-
- -
-
- - -
-
-
+
diff --git a/src/Web/Grand.Web.Admin/Models/Settings/VendorSettingsModel.cs b/src/Web/Grand.Web.Admin/Models/Settings/VendorSettingsModel.cs index 093a6c0ee..eb5841254 100644 --- a/src/Web/Grand.Web.Admin/Models/Settings/VendorSettingsModel.cs +++ b/src/Web/Grand.Web.Admin/Models/Settings/VendorSettingsModel.cs @@ -36,8 +36,6 @@ public VendorSettingsModel() [GrandResourceDisplayName("Admin.Settings.Vendor.TermsOfServiceEnabled")] public bool TermsOfServiceEnabled { get; set; } - [GrandResourceDisplayName("Admin.Settings.Vendor.AllowToUploadFile")] - public bool AllowToUploadFile { get; set; } //review vendor [GrandResourceDisplayName("Admin.Settings.Vendor.VendorReviewsMustBeApproved")] public bool VendorReviewsMustBeApproved { get; set; } diff --git a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml index f6c6b25d3..db360d8b8 100644 --- a/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml +++ b/src/Web/Grand.Web/App_Data/Resources/DefaultLanguage.xml @@ -11424,9 +11424,6 @@ Allow customers to contact vendors - - Allow vendor to upload picture file - Allow search by vendor in store advanced search diff --git a/src/Web/Grand.Web/Controllers/VendorController.cs b/src/Web/Grand.Web/Controllers/VendorController.cs index a972bbf9e..91c620da5 100644 --- a/src/Web/Grand.Web/Controllers/VendorController.cs +++ b/src/Web/Grand.Web/Controllers/VendorController.cs @@ -14,7 +14,6 @@ using Grand.SharedKernel.Extensions; using Grand.Web.Commands.Models.Vendors; using Grand.Web.Common.Controllers; -using Grand.Web.Common.Extensions; using Grand.Web.Common.Filters; using Grand.Web.Common.Security.Authorization; using Grand.Web.Common.Security.Captcha; @@ -113,7 +112,6 @@ public virtual async Task ApplyVendor() model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnApplyVendorPage; model.Email = _workContext.CurrentCustomer.Email; model.TermsOfServiceEnabled = _vendorSettings.TermsOfServiceEnabled; - model.AllowToUploadFile = _vendorSettings.AllowToUploadFile; model.TermsOfServicePopup = _commonSettings.PopupForTermsOfServiceLinks; var countries = await _countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id); model.Address = await _mediator.Send(new GetVendorAddress { @@ -137,28 +135,6 @@ public virtual async Task ApplyVendorSubmit(ApplyVendorModel mode if (!_vendorSettings.AllowCustomersToApplyForVendorAccount) return RedirectToRoute("HomePage"); - var contentType = string.Empty; - byte[] vendorPictureBinary = null; - - if (_vendorSettings.AllowToUploadFile && uploadedFile != null && !string.IsNullOrEmpty(uploadedFile.FileName)) - { - try - { - contentType = uploadedFile.ContentType; - if (string.IsNullOrEmpty(contentType)) - ModelState.AddModelError("", "Empty content type"); - else - if (!contentType.StartsWith("image")) - ModelState.AddModelError("", "Only image content type is allowed"); - - vendorPictureBinary = uploadedFile.GetPictureBits(); - } - catch (Exception) - { - ModelState.AddModelError("", _translationService.GetResource("Vendors.ApplyAccount.Picture.ErrorMessage")); - } - } - if (ModelState.IsValid) { var description = FormatText.ConvertText(model.Description); @@ -173,13 +149,7 @@ public virtual async Task ApplyVendorSubmit(ApplyVendorModel mode AllowCustomerReviews = _vendorSettings.DefaultAllowCustomerReview }; model.Address.ToEntity(vendor.Address); - if (vendorPictureBinary != null && !string.IsNullOrEmpty(contentType)) - { - var picture = await _pictureService.InsertPicture(vendorPictureBinary, contentType, null, reference: Reference.Vendor, objectId: vendor.Id); - if (picture != null) - vendor.PictureId = picture.Id; - } - + await _vendorService.InsertVendor(vendor); //search engine name (the same as vendor name) @@ -209,7 +179,6 @@ await _messageProviderService.SendNewVendorAccountApplyStoreOwnerMessage(_workCo model.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnApplyVendorPage; model.TermsOfServiceEnabled = _vendorSettings.TermsOfServiceEnabled; model.TermsOfServicePopup = _commonSettings.PopupForTermsOfServiceLinks; - model.AllowToUploadFile = _vendorSettings.AllowToUploadFile; var countries = await _countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id); model.Address = await _mediator.Send(new GetVendorAddress { Language = _workContext.WorkingLanguage, @@ -222,133 +191,7 @@ await _messageProviderService.SendNewVendorAccountApplyStoreOwnerMessage(_workCo }); return View(model); } - - [HttpGet] - [CustomerGroupAuthorize(SystemCustomerGroupNames.Registered)] - public virtual async Task Info() - { - if (_workContext.CurrentVendor == null || !_vendorSettings.AllowVendorsToEditInfo) - return RedirectToRoute("CustomerInfo"); - - var model = new VendorInfoModel(); - var vendor = _workContext.CurrentVendor; - model.Description = vendor.Description; - model.Email = vendor.Email; - model.Name = vendor.Name; - model.UserFields = vendor.UserFields; - model.AllowToUploadFile = _vendorSettings.AllowToUploadFile; - model.PictureUrl = await _pictureService.GetPictureUrl(vendor.PictureId); - var countries = await _countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id); - model.Address = await _mediator.Send(new GetVendorAddress { - Language = _workContext.WorkingLanguage, - Address = vendor.Address, - ExcludeProperties = false, - LoadCountries = () => countries - }); - - return View(model); - } - - [HttpPost] - [AutoValidateAntiforgeryToken] - [CustomerGroupAuthorize(SystemCustomerGroupNames.Registered)] - public virtual async Task Info(VendorInfoModel model, IFormFile uploadedFile) - { - if (_workContext.CurrentVendor == null || !_vendorSettings.AllowVendorsToEditInfo) - return RedirectToRoute("CustomerInfo"); - - var contentType = string.Empty; - byte[] vendorPictureBinary = null; - - if (_vendorSettings.AllowToUploadFile && uploadedFile != null && !string.IsNullOrEmpty(uploadedFile.FileName)) - { - try - { - contentType = uploadedFile.ContentType; - if (string.IsNullOrEmpty(contentType)) - ModelState.AddModelError("", "Empty content type"); - else - if (!contentType.StartsWith("image")) - ModelState.AddModelError("", "Only image content type is allowed"); - - vendorPictureBinary = uploadedFile.GetPictureBits(); - } - catch (Exception) - { - ModelState.AddModelError("", _translationService.GetResource("Account.VendorInfo.Picture.ErrorMessage")); - } - } - - var vendor = _workContext.CurrentVendor; - var prevPicture = await _pictureService.GetPictureById(vendor.PictureId); - if (prevPicture == null) - vendor.PictureId = ""; - - if (ModelState.IsValid) - { - var description = FormatText.ConvertText(model.Description); - - vendor.Name = model.Name; - vendor.Email = model.Email; - vendor.Description = description; - - if (vendorPictureBinary != null && !string.IsNullOrEmpty(contentType)) - { - var picture = await _pictureService.InsertPicture(vendorPictureBinary, contentType, null, reference: Reference.Vendor, objectId: vendor.Id); - if (picture != null) - vendor.PictureId = picture.Id; - - if (prevPicture != null) - await _pictureService.DeletePicture(prevPicture); - } - //update picture seo file name - await UpdatePictureSeoNames(vendor); - model.Address.ToEntity(vendor.Address); - - await _vendorService.UpdateVendor(vendor); - - //notifications - if (_vendorSettings.NotifyStoreOwnerAboutVendorInformationChange) - await _messageProviderService.SendVendorInformationChangeMessage(vendor, _workContext.CurrentStore, _languageSettings.DefaultAdminLanguageId); - - return RedirectToAction("Info"); - } - var countries = await _countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id); - model.Address = await _mediator.Send(new GetVendorAddress { - Language = _workContext.WorkingLanguage, - Model = model.Address, - Address = vendor.Address, - ExcludeProperties = false, - LoadCountries = () => countries - }); - - return View(model); - } - - [HttpGet] - [CustomerGroupAuthorize(SystemCustomerGroupNames.Registered)] - public virtual async Task RemovePicture() - { - if (_workContext.CurrentVendor == null || !_vendorSettings.AllowVendorsToEditInfo) - return RedirectToRoute("CustomerInfo"); - - var vendor = _workContext.CurrentVendor; - var picture = await _pictureService.GetPictureById(vendor.PictureId); - - if (picture != null) - await _pictureService.DeletePicture(picture); - - vendor.PictureId = ""; - await _vendorService.UpdateVendor(vendor); - - //notifications - if (_vendorSettings.NotifyStoreOwnerAboutVendorInformationChange) - await _messageProviderService.SendVendorInformationChangeMessage(vendor, _workContext.CurrentStore, _languageSettings.DefaultAdminLanguageId); - - return RedirectToAction("Info"); - } - - + [HttpPost] [AutoValidateAntiforgeryToken] [DenySystemAccount] diff --git a/src/Web/Grand.Web/Features/Handlers/Customers/GetNavigationHandler.cs b/src/Web/Grand.Web/Features/Handlers/Customers/GetNavigationHandler.cs index 89f99f4e4..4f246c52c 100644 --- a/src/Web/Grand.Web/Features/Handlers/Customers/GetNavigationHandler.cs +++ b/src/Web/Grand.Web/Features/Handlers/Customers/GetNavigationHandler.cs @@ -42,10 +42,6 @@ public async Task Handle(GetNavigation request, Cancell HideCourses = _customerSettings.HideCoursesTab, HideSubAccounts = _customerSettings.HideSubAccountsTab || !string.IsNullOrEmpty(request.Customer.OwnerId) }; - if (_vendorSettings.AllowVendorsToEditInfo && request.Vendor != null) - { - model.ShowVendorInfo = true; - } model.SelectedTab = (AccountNavigationEnum)request.SelectedTabId; return await Task.FromResult(model); diff --git a/src/Web/Grand.Web/Models/Customer/CustomerNavigationModel.cs b/src/Web/Grand.Web/Models/Customer/CustomerNavigationModel.cs index 192d55ac2..712d1ef4e 100644 --- a/src/Web/Grand.Web/Models/Customer/CustomerNavigationModel.cs +++ b/src/Web/Grand.Web/Models/Customer/CustomerNavigationModel.cs @@ -16,7 +16,6 @@ public class CustomerNavigationModel : BaseModel public bool HideAuctions { get; set; } public bool HideNotes { get; set; } public bool HideDocuments { get; set; } - public bool ShowVendorInfo { get; set; } public bool HideReviews { get; set; } public bool HideCourses { get; set; } public bool HideSubAccounts { get; set; } diff --git a/src/Web/Grand.Web/Models/Vendors/ApplyVendorModel.cs b/src/Web/Grand.Web/Models/Vendors/ApplyVendorModel.cs index b54316963..5d0bb707c 100644 --- a/src/Web/Grand.Web/Models/Vendors/ApplyVendorModel.cs +++ b/src/Web/Grand.Web/Models/Vendors/ApplyVendorModel.cs @@ -27,7 +27,6 @@ public ApplyVendorModel() public bool TermsOfServiceEnabled { get; set; } public bool TermsOfServicePopup { get; set; } public bool DisableFormInput { get; set; } - public bool AllowToUploadFile { get; set; } public string Result { get; set; } } } \ No newline at end of file diff --git a/src/Web/Grand.Web/Models/Vendors/VendorInfoModel.cs b/src/Web/Grand.Web/Models/Vendors/VendorInfoModel.cs deleted file mode 100644 index 726096e66..000000000 --- a/src/Web/Grand.Web/Models/Vendors/VendorInfoModel.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Grand.Infrastructure.ModelBinding; -using Grand.Infrastructure.Models; - -namespace Grand.Web.Models.Vendors -{ - public class VendorInfoModel : BaseModel - { - public VendorInfoModel() - { - Address = new VendorAddressModel(); - } - - [GrandResourceDisplayName("Account.VendorInfo.Name")] - public string Name { get; set; } - - [GrandResourceDisplayName("Account.VendorInfo.Email")] - public string Email { get; set; } - - [GrandResourceDisplayName("Account.VendorInfo.Description")] - public string Description { get; set; } - - [GrandResourceDisplayName("Account.VendorInfo.Picture")] - public string PictureUrl { get; set; } - public bool AllowToUploadFile { get; set; } - public VendorAddressModel Address { get; set; } - } -} \ No newline at end of file diff --git a/src/Web/Grand.Web/Validators/Vendors/VendorInfoValidator.cs b/src/Web/Grand.Web/Validators/Vendors/VendorInfoValidator.cs deleted file mode 100644 index 55eb300ab..000000000 --- a/src/Web/Grand.Web/Validators/Vendors/VendorInfoValidator.cs +++ /dev/null @@ -1,25 +0,0 @@ -using FluentValidation; -using Grand.Business.Core.Interfaces.Common.Directory; -using Grand.Business.Core.Interfaces.Common.Localization; -using Grand.Domain.Vendors; -using Grand.Infrastructure.Validators; -using Grand.Web.Models.Vendors; - -namespace Grand.Web.Validators.Vendors -{ - public class VendorInfoValidator : BaseGrandValidator - { - public VendorInfoValidator( - IEnumerable> validators, - IEnumerable> addressvalidators, - ITranslationService translationService, - ICountryService countryService, VendorSettings addressSettings) - : base(validators) - { - RuleFor(x => x.Name).NotEmpty().WithMessage(translationService.GetResource("Account.VendorInfo.Name.Required")); - RuleFor(x => x.Email).NotEmpty().WithMessage(translationService.GetResource("Account.VendorInfo.Email.Required")); - RuleFor(x => x.Email).EmailAddress().WithMessage(translationService.GetResource("Common.WrongEmail")); - RuleFor(x => x.Address).SetValidator(new VendorAddressValidator(addressvalidators, translationService, countryService, addressSettings)); - } - } -} \ No newline at end of file diff --git a/src/Web/Grand.Web/Views/Shared/Components/CustomerNavigation/Default.cshtml b/src/Web/Grand.Web/Views/Shared/Components/CustomerNavigation/Default.cshtml index 9efb82b14..b6beaf583 100644 --- a/src/Web/Grand.Web/Views/Shared/Components/CustomerNavigation/Default.cshtml +++ b/src/Web/Grand.Web/Views/Shared/Components/CustomerNavigation/Default.cshtml @@ -1,154 +1,132 @@ @model CustomerNavigationModel +
\ No newline at end of file diff --git a/src/Web/Grand.Web/Views/Vendor/ApplyVendor.cshtml b/src/Web/Grand.Web/Views/Vendor/ApplyVendor.cshtml index e211aa767..22a2db34c 100644 --- a/src/Web/Grand.Web/Views/Vendor/ApplyVendor.cshtml +++ b/src/Web/Grand.Web/Views/Vendor/ApplyVendor.cshtml @@ -47,15 +47,6 @@
- @if (Model.AllowToUploadFile) - { -
- -
- -
-
- } @if (Model.DisplayCaptcha) {
diff --git a/src/Web/Grand.Web/Views/Vendor/Info.cshtml b/src/Web/Grand.Web/Views/Vendor/Info.cshtml deleted file mode 100644 index 577637ce1..000000000 --- a/src/Web/Grand.Web/Views/Vendor/Info.cshtml +++ /dev/null @@ -1,86 +0,0 @@ -@model VendorInfoModel -@inject IPageHeadBuilder pagebuilder -@{ - Layout = "_TwoColumns"; - - //title - pagebuilder.AddTitleParts(Loc["Title.Vendorinfo"]); -} -@section left -{ - @await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.VendorInfo }) -} -
-

@Loc["Account.MyAccount"] - @Loc["Account.VendorInfo"]

- -
-
-
-
- - - * - - {{ errors[0] }} - - -
-
- - - * - - {{ errors[0] }} - - -
-
- - -
- @if (Model.AllowToUploadFile) - { -
- - - @if (!string.IsNullOrEmpty(Model.PictureUrl)) - { - - } -
- } - @{ - var dataDictAddress = new ViewDataDictionary(ViewData) - { - TemplateInfo = - { - HtmlFieldPrefix = "Address" - } - }; - - } -
-
-
- -
-
-
-
-
- \ No newline at end of file