2013-08-20 11:33:41 +10:00
|
|
|
|
using System;
|
|
|
|
|
|
using AutoMapper;
|
2013-08-12 15:06:12 +02:00
|
|
|
|
using Umbraco.Core.Models;
|
|
|
|
|
|
using Umbraco.Core.Models.Mapping;
|
2013-08-20 11:33:41 +10:00
|
|
|
|
using Umbraco.Core.Services;
|
2013-08-12 15:06:12 +02:00
|
|
|
|
using Umbraco.Web.Models.ContentEditing;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Models.Mapping
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// A mapper which declares how to map content properties. These mappings are shared among media (and probably members) which is
|
|
|
|
|
|
/// why they are in their own mapper
|
|
|
|
|
|
/// </summary>
|
2016-03-22 16:29:04 +01:00
|
|
|
|
internal class ContentPropertyModelMapper : ModelMapperConfiguration
|
2013-08-12 15:06:12 +02:00
|
|
|
|
{
|
2016-09-01 19:06:08 +02:00
|
|
|
|
private readonly IDataTypeService _dataTypeService;
|
|
|
|
|
|
|
|
|
|
|
|
public ContentPropertyModelMapper(IDataTypeService dataTypeService)
|
|
|
|
|
|
{
|
|
|
|
|
|
_dataTypeService = dataTypeService;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void ConfigureMappings(IMapperConfiguration config)
|
2013-08-12 15:06:12 +02:00
|
|
|
|
{
|
2016-09-01 19:06:08 +02:00
|
|
|
|
var lazyDataTypeService = new Lazy<IDataTypeService>(() => _dataTypeService);
|
2013-08-20 11:33:41 +10:00
|
|
|
|
|
2013-08-12 15:06:12 +02:00
|
|
|
|
//FROM Property TO ContentPropertyBasic
|
|
|
|
|
|
config.CreateMap<PropertyGroup, Tab<ContentPropertyDisplay>>()
|
2014-04-14 15:20:02 +10:00
|
|
|
|
.ForMember(tab => tab.Label, expression => expression.MapFrom(@group => @group.Name))
|
|
|
|
|
|
.ForMember(tab => tab.IsActive, expression => expression.UseValue(true))
|
|
|
|
|
|
.ForMember(tab => tab.Properties, expression => expression.Ignore())
|
|
|
|
|
|
.ForMember(tab => tab.Alias, expression => expression.Ignore());
|
2013-08-12 15:06:12 +02:00
|
|
|
|
|
|
|
|
|
|
//FROM Property TO ContentPropertyBasic
|
|
|
|
|
|
config.CreateMap<Property, ContentPropertyBasic>()
|
2013-11-19 11:51:01 +11:00
|
|
|
|
.ConvertUsing(new ContentPropertyBasicConverter<ContentPropertyBasic>(lazyDataTypeService));
|
2013-08-12 15:06:12 +02:00
|
|
|
|
|
|
|
|
|
|
//FROM Property TO ContentPropertyDto
|
|
|
|
|
|
config.CreateMap<Property, ContentPropertyDto>()
|
2013-08-20 11:33:41 +10:00
|
|
|
|
.ConvertUsing(new ContentPropertyDtoConverter(lazyDataTypeService));
|
2013-08-12 15:06:12 +02:00
|
|
|
|
|
|
|
|
|
|
//FROM Property TO ContentPropertyDisplay
|
|
|
|
|
|
config.CreateMap<Property, ContentPropertyDisplay>()
|
2013-08-20 11:33:41 +10:00
|
|
|
|
.ConvertUsing(new ContentPropertyDisplayConverter(lazyDataTypeService));
|
2013-08-12 15:06:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2013-07-25 16:08:18 +10:00
|
|
|
|
}
|