-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Admin panel - Knowledgebase settings - use automapper
- Loading branch information
1 parent
ca30207
commit a64a6b4
Showing
3 changed files
with
41 additions
and
8 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
18 changes: 18 additions & 0 deletions
18
src/Web/Grand.Web.Admin/Extensions/Mapping/Settings/KnowledgebaseMappingExtensions.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,18 @@ | ||
using Grand.Domain.Knowledgebase; | ||
using Grand.Infrastructure.Mapper; | ||
using Grand.Web.Admin.Models.Settings; | ||
|
||
namespace Grand.Web.Admin.Extensions | ||
{ | ||
public static class KnowledgebaseSettingsMappingExtensions | ||
{ | ||
public static ContentSettingsModel.KnowledgebaseSettingsModel ToModel(this KnowledgebaseSettings entity) | ||
{ | ||
return entity.MapTo<KnowledgebaseSettings, ContentSettingsModel.KnowledgebaseSettingsModel>(); | ||
} | ||
public static KnowledgebaseSettings ToEntity(this ContentSettingsModel.KnowledgebaseSettingsModel model, KnowledgebaseSettings destination) | ||
{ | ||
return model.MapTo(destination); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Web/Grand.Web.Admin/Mapper/KnowledgebaseSettingsProfile.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,19 @@ | ||
using AutoMapper; | ||
using Grand.Domain.Knowledgebase; | ||
using Grand.Infrastructure.Mapper; | ||
using Grand.Web.Admin.Models.Settings; | ||
|
||
namespace Grand.Web.Admin.Mapper | ||
{ | ||
public class KnowledgebaseSettingsProfile : Profile, IAutoMapperProfile | ||
{ | ||
public KnowledgebaseSettingsProfile() | ||
{ | ||
CreateMap<KnowledgebaseSettings, ContentSettingsModel.KnowledgebaseSettingsModel>() | ||
.ForMember(dest => dest.UserFields, mo => mo.Ignore()); | ||
CreateMap<ContentSettingsModel.KnowledgebaseSettingsModel, KnowledgebaseSettings>(); | ||
} | ||
|
||
public int Order => 0; | ||
} | ||
} |