Changed over the content/media type mappers to be auto-mapper based

This commit is contained in:
Shannon
2013-08-05 19:29:47 +10:00
parent ab594db5fc
commit 968e6224c7
9 changed files with 29 additions and 85 deletions

View File

@@ -20,21 +20,6 @@ namespace Umbraco.Web.Models.Mapping
UserMapper = userMapper;
}
//protected ContentItemDto<TPersisted> ToContentItemDtoBase<TPersisted>(IContentBase content)
// where TPersisted : IContentBase
//{
// return CreateContent<ContentItemDto<TPersisted>, ContentPropertyDto, TPersisted>(content, null, (propertyDto, originalProperty, propEditor) =>
// {
// propertyDto.IsRequired = originalProperty.PropertyType.Mandatory;
// propertyDto.ValidationRegExp = originalProperty.PropertyType.ValidationRegExp;
// propertyDto.Alias = originalProperty.Alias;
// propertyDto.Description = originalProperty.PropertyType.Description;
// propertyDto.Label = originalProperty.PropertyType.Name;
// propertyDto.DataType = ApplicationContext.Services.DataTypeService.GetDataTypeDefinitionById(originalProperty.PropertyType.DataTypeDefinitionId);
// propertyDto.PropertyEditor = PropertyEditorResolver.Current.GetById(originalProperty.PropertyType.DataTypeId);
// });
//}
protected ContentItemBasic<ContentPropertyBasic, TPersisted> ToContentItemSimpleBase<TPersisted>(IContentBase content)
where TPersisted : IContentBase
{

View File

@@ -1,28 +0,0 @@
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Web.Models.ContentEditing;
namespace Umbraco.Web.Models.Mapping
{
internal class ContentTypeModelMapper
{
private readonly ApplicationContext _applicationContext;
public ContentTypeModelMapper(ApplicationContext applicationContext)
{
_applicationContext = applicationContext;
}
public ContentTypeBasic ToContentTypeBasic(IContentType contentType)
{
return new ContentTypeBasic
{
Alias = contentType.Alias,
Id = contentType.Id,
Description = contentType.Description,
Icon = contentType.Icon,
Name = contentType.Name
};
}
}
}

View File

@@ -1,28 +1,20 @@
using Umbraco.Core;
using AutoMapper;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Mapping;
using Umbraco.Web.Models.ContentEditing;
namespace Umbraco.Web.Models.Mapping
{
internal class MediaTypeModelMapper
{
private readonly ApplicationContext _applicationContext;
public MediaTypeModelMapper(ApplicationContext applicationContext)
/// <summary>
/// Defines mappings for content/media (and i'm sure one day member) type mappings
/// </summary>
internal class ContentTypeModelMapper : MapperConfiguration
{
public override void ConfigureMappings(IConfiguration config, ApplicationContext applicationContext)
{
_applicationContext = applicationContext;
}
public ContentTypeBasic ToMediaTypeBasic(IMediaType contentType)
{
return new ContentTypeBasic
{
Alias = contentType.Alias,
Id = contentType.Id,
Description = contentType.Description,
Icon = contentType.Icon,
Name = contentType.Name
};
config.CreateMap<IMediaType, ContentTypeBasic>();
config.CreateMap<IContentType, ContentTypeBasic>();
}
}
}