Started integrating authorization services.

This commit is contained in:
Shannon
2013-06-17 01:06:31 +02:00
parent 9cc95aba0e
commit b50658121d
25 changed files with 276 additions and 80 deletions

View File

@@ -0,0 +1,42 @@
using System;
using Umbraco.Core;
using Umbraco.Core.Models.Membership;
using Umbraco.Web.Models.ContentEditing;
namespace Umbraco.Web.Models.Mapping
{
internal class UserModelMapper
{
public UserDetail ToUserDetail(IUser user)
{
var detail = new UserDetail
{
Name = user.Name,
Email = user.Email,
Language = user.Language
};
var result = user.Id.TryConvertTo<int>();
if (result.Success == false)
{
throw new InvalidOperationException("Cannot convert the profile to a " + typeof(UserDetail).Name + " object since the id is not an integer");
}
detail.UserId = result.Result;
return detail;
}
public UserBasic ToUserBasic(IProfile profile)
{
var user = new UserBasic
{
Name = profile.Name
};
var result = profile.Id.TryConvertTo<int>();
if (result.Success == false)
{
throw new InvalidOperationException("Cannot convert the profile to a " + typeof(UserBasic).Name + " object since the id is not an integer");
}
user.UserId = result.Result;
return user;
}
}
}