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

31 lines
865 B
C#
Raw Normal View History

2018-06-29 19:52:40 +02:00
using AutoMapper;
using Umbraco.Core;
2018-06-29 19:52:40 +02:00
using Umbraco.Core.Models;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Services;
using UserProfile = Umbraco.Web.Models.ContentEditing.UserProfile;
namespace Umbraco.Web.Models.Mapping
{
/// <summary>
/// Maps the Owner for IContentBase
/// </summary>
/// <typeparam name="TPersisted"></typeparam>
internal class OwnerResolver<TPersisted>
where TPersisted : IContentBase
{
private readonly IUserService _userService;
public OwnerResolver(IUserService userService)
{
_userService = userService;
}
public UserProfile Resolve(TPersisted source)
{
var profile = source.GetCreatorProfile(_userService);
return profile == null ? null : Mapper.Map<IProfile, UserProfile>(profile);
2018-06-29 19:52:40 +02:00
}
}
}