upgraded other projs to 4.5, added page to render for back office for, now to get requirejs wired up properly as its not returning the correct
paths.
This commit is contained in:
67
src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs
Normal file
67
src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
//TODO: Convert this over to mapping engine if people agree to it
|
||||
internal class ContentModelMapper
|
||||
{
|
||||
private readonly ApplicationContext _applicationContext;
|
||||
|
||||
public ContentModelMapper(ApplicationContext applicationContext)
|
||||
{
|
||||
_applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public ContentItemDisplay ToContentItemDisplay(IContent content)
|
||||
{
|
||||
return new ContentItemDisplay
|
||||
{
|
||||
Id = content.Id,
|
||||
Name = content.Name,
|
||||
Properties = content.Properties.Select(p =>
|
||||
{
|
||||
var editor = PropertyEditorResolver.Current.GetById(p.PropertyType.DataTypeId);
|
||||
if (editor == null)
|
||||
{
|
||||
throw new NullReferenceException("The property editor with id " + p.PropertyType.DataTypeId + " does not exist");
|
||||
}
|
||||
return new ContentPropertyDisplay
|
||||
{
|
||||
Alias = p.Alias,
|
||||
Id = p.Id,
|
||||
Description = p.PropertyType.Description,
|
||||
Label = p.PropertyType.Name,
|
||||
Config = _applicationContext.Services.DataTypeService.GetPreValueAsString(p.PropertyType.DataTypeDefinitionId),
|
||||
Value = p.Value.ToString(),
|
||||
View = editor.ValueEditor.View
|
||||
};
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
public ContentItemDto ToContentItemDto(IContent content)
|
||||
{
|
||||
return new ContentItemDto
|
||||
{
|
||||
Id = content.Id,
|
||||
Properties = content.Properties.Select(p => new ContentPropertyDto
|
||||
{
|
||||
Alias = p.Alias,
|
||||
Description = p.PropertyType.Description,
|
||||
Label = p.PropertyType.Name,
|
||||
Id = p.Id,
|
||||
DataType = _applicationContext.Services.DataTypeService.GetDataTypeDefinitionById(p.PropertyType.DataTypeDefinitionId)
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user