-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Admin panel - Theme list - use automapper
- Loading branch information
1 parent
586781f
commit 7c1e4b6
Showing
3 changed files
with
46 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/Web/Grand.Web.Admin/Extensions/Mapping/Settings/ThemeConfigurationMappingExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Grand.Infrastructure.Mapper; | ||
using Grand.Web.Admin.Models.Settings; | ||
using Grand.Web.Common.Themes; | ||
using System; | ||
|
||
namespace Grand.Web.Admin.Extensions | ||
{ | ||
public static class ThemeConfigurationMappingExtensions | ||
{ | ||
public static GeneralCommonSettingsModel.StoreInformationSettingsModel.ThemeConfigurationModel ToModel(this ThemeConfiguration entity, string defaultStoreTheme) | ||
{ | ||
var result = entity.MapTo<ThemeConfiguration, GeneralCommonSettingsModel.StoreInformationSettingsModel.ThemeConfigurationModel>(); | ||
result.Selected = result.ThemeName.Equals(defaultStoreTheme, StringComparison.OrdinalIgnoreCase); | ||
return result; | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Web/Grand.Web.Admin/Mapper/ThemeConfigurationProfile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using AutoMapper; | ||
using Grand.Infrastructure.Mapper; | ||
using Grand.Web.Admin.Models.Settings; | ||
using Grand.Web.Common.Themes; | ||
|
||
namespace Grand.Web.Admin.Mapper | ||
{ | ||
public class ThemeConfigurationProfile : Profile, IAutoMapperProfile | ||
{ | ||
public ThemeConfigurationProfile() | ||
{ | ||
CreateMap<ThemeConfiguration, GeneralCommonSettingsModel.StoreInformationSettingsModel.ThemeConfigurationModel>() | ||
.ForMember(dest => dest.ThemeTitle, mo => mo.MapFrom(p => p.Title)) | ||
.ForMember(dest => dest.ThemeName, mo => mo.MapFrom(p => p.Name)) | ||
.ForMember(dest => dest.ThemeVersion, mo => mo.MapFrom(p => p.Version)); | ||
} | ||
|
||
public int Order => 0; | ||
} | ||
} |