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 with page model mapping
KrzysztofPajak5e15870aa2c4
diff --git a/src/Web/Grand.Web/Extensions/MappingExtensions.cs b/src/Web/Grand.Web/Extensions/MappingExtensions.csindex f57d875b0..dfb752b52 100644--- a/src/Web/Grand.Web/Extensions/MappingExtensions.cs+++ b/src/Web/Grand.Web/Extensions/MappingExtensions.cs@@ -1,15 +1,12 @@using Grand.Business.Core.Extensions;-using Grand.Business.Core.Interfaces.Common.Directory;using Grand.Domain.Catalog;using Grand.Domain.Common;using Grand.Domain.Courses;using Grand.Domain.Customers;using Grand.Domain.Localization;-using Grand.Domain.Pages;using Grand.Web.Models.Catalog;using Grand.Web.Models.Common;using Grand.Web.Models.Course;-using Grand.Web.Models.Pages;using Grand.Web.Models.Vendors;using System.Globalization;@@ -102,38 +99,7 @@ public static class MappingExtensions};return model;}--- //page- public static PageModel ToModel(this Page entity, Language language, IDateTimeService dateTimeService,- string password = "")- {- var model = new PageModel {- Id = entity.Id,- SystemName = entity.SystemName,- IncludeInSitemap = entity.IncludeInSitemap,- IsPasswordProtected = entity.IsPasswordProtected,- Password = entity.Password == password ? password : "",- Title = entity.IsPasswordProtected && entity.Password != password- ? ""- : entity.GetTranslation(x => x.Title, language.Id),- Body = entity.IsPasswordProtected && entity.Password != password- ? ""- : entity.GetTranslation(x => x.Body, language.Id),- MetaKeywords = entity.GetTranslation(x => x.MetaKeywords, language.Id),- MetaDescription = entity.GetTranslation(x => x.MetaDescription, language.Id),- MetaTitle = entity.GetTranslation(x => x.MetaTitle, language.Id),- SeName = entity.GetSeName(language.Id),- PageLayoutId = entity.PageLayoutId,- Published = entity.Published,- StartDate = entity.StartDateUtc.HasValue- ? dateTimeService.ConvertToUserTime(entity.StartDateUtc.Value)- : default,- EndDate = entity.EndDateUtc.HasValue ? dateTimeService.ConvertToUserTime(entity.EndDateUtc.Value) : default- };- return model;- }-+public static Address ToEntity(this AddressModel model, Customer customer, AddressSettings addressSettings,bool trimFields = true){diff --git a/src/Web/Grand.Web/Features/Handlers/Pages/GetPageBlockHandler.cs b/src/Web/Grand.Web/Features/Handlers/Pages/GetPageBlockHandler.csindex 020e128d1..d6eed7c09 100644--- a/src/Web/Grand.Web/Features/Handlers/Pages/GetPageBlockHandler.cs+++ b/src/Web/Grand.Web/Features/Handlers/Pages/GetPageBlockHandler.cs@@ -1,8 +1,10 @@-using Grand.Business.Core.Interfaces.Cms;+using Grand.Business.Core.Extensions;+using Grand.Business.Core.Interfaces.Cms;using Grand.Business.Core.Interfaces.Common.Directory;using Grand.Business.Core.Interfaces.Common.Security;+using Grand.Domain.Localization;+using Grand.Domain.Pages;using Grand.Infrastructure;-using Grand.Web.Extensions;using Grand.Web.Features.Models.Pages;using Grand.Web.Models.Pages;using MediatR;@@ -45,6 +47,36 @@ public class GetPageBlockHandler : IRequestHandler<GetPageBlock, PageModel>//ACL (access control list)return !_aclService.Authorize(page, _workContext.CurrentCustomer)? null- : page.ToModel(_workContext.WorkingLanguage, _dateTimeService, request.Password);+ : ToModel(page, _workContext.WorkingLanguage, request.Password);}++ private PageModel ToModel(Page entity, Language language,+ string password = "")+ {+ var model = new PageModel {+ Id = entity.Id,+ SystemName = entity.SystemName,+ IncludeInSitemap = entity.IncludeInSitemap,+ IsPasswordProtected = entity.IsPasswordProtected,+ Password = entity.Password == password ? password : "",+ Title = entity.IsPasswordProtected && entity.Password != password+ ? ""+ : entity.GetTranslation(x => x.Title, language.Id),+ Body = entity.IsPasswordProtected && entity.Password != password+ ? ""+ : entity.GetTranslation(x => x.Body, language.Id),+ MetaKeywords = entity.GetTranslation(x => x.MetaKeywords, language.Id),+ MetaDescription = entity.GetTranslation(x => x.MetaDescription, language.Id),+ MetaTitle = entity.GetTranslation(x => x.MetaTitle, language.Id),+ SeName = entity.GetSeName(language.Id),+ PageLayoutId = entity.PageLayoutId,+ Published = entity.Published,+ StartDate = entity.StartDateUtc.HasValue+ ? _dateTimeService.ConvertToUserTime(entity.StartDateUtc.Value)+ : default,+ EndDate = entity.EndDateUtc.HasValue ? _dateTimeService.ConvertToUserTime(entity.EndDateUtc.Value) : default+ };+ return model;+ }+}\ No newline at end of file