Files
Umbraco-CMS/src/Umbraco.Web/Models/Mapping/SectionModelMapper.cs

27 lines
924 B
C#
Raw Normal View History

2016-03-15 16:39:17 +01:00
using System.Collections.Generic;
using AutoMapper;
using Umbraco.Core.Services;
using Umbraco.Core.Models.Mapping;
using Umbraco.Web.Models.ContentEditing;
namespace Umbraco.Web.Models.Mapping
{
internal class SectionModelMapper : ModelMapperConfiguration
{
private readonly ILocalizedTextService _textService;
public SectionModelMapper(ILocalizedTextService textService)
{
_textService = textService;
}
public override void ConfigureMappings(IMapperConfiguration config)
{
config.CreateMap<Core.Models.Section, Section>()
2013-10-09 15:04:30 +02:00
.ForMember(
dto => dto.Name,
expression => expression.MapFrom(section => _textService.Localize("sections/" + section.Alias, (IDictionary<string, string>)null)))
.ReverseMap(); //backwards too!
}
}
}