real data for user group
This commit is contained in:
@@ -164,42 +164,16 @@
|
||||
"Failed to save user");
|
||||
}
|
||||
|
||||
function getUserGroup() {
|
||||
var deferred = $q.defer();
|
||||
var user = {
|
||||
"name": "Admin",
|
||||
"alias": "admin",
|
||||
"id": 1,
|
||||
"icon": "icon-medal",
|
||||
"users": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Angela Stone",
|
||||
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/jina/128.jpg",
|
||||
"state": "active"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Beverly Silva",
|
||||
"avatar": "",
|
||||
"state": "disabled"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "Ruth Turner",
|
||||
"avatar": "",
|
||||
"state": "pending"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name": "Arthur Welch",
|
||||
"avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/ashleyford/128.jpg",
|
||||
"state": "active"
|
||||
}
|
||||
]
|
||||
};
|
||||
deferred.resolve(user);
|
||||
return deferred.promise;
|
||||
function getUserGroup(id) {
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"userApiBaseUrl",
|
||||
"GetUserGroup",
|
||||
{ id: id })),
|
||||
"Failed to retrieve data for user group " + id);
|
||||
|
||||
}
|
||||
|
||||
function getUserGroups() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function UserGroupEditController($scope, $timeout, $location, usersResource) {
|
||||
function UserGroupEditController($scope, $timeout, $location, usersResource, $routeParams) {
|
||||
|
||||
var vm = this;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
vm.loading = true;
|
||||
|
||||
// get user
|
||||
usersResource.getUserGroup().then(function (userGroup) {
|
||||
usersResource.getUserGroup($routeParams.id).then(function (userGroup) {
|
||||
vm.userGroup = userGroup;
|
||||
makeBreadcrumbs();
|
||||
});
|
||||
|
||||
@@ -164,9 +164,22 @@ namespace Umbraco.Web.Editors
|
||||
/// Returns all user groups
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<UserGroupDisplay> GetUserGroups()
|
||||
public IEnumerable<UserGroupBasic> GetUserGroups()
|
||||
{
|
||||
return Mapper.Map<IEnumerable<IUserGroup>, IEnumerable<UserGroupDisplay>>(Services.UserService.GetAllUserGroups());
|
||||
return Mapper.Map<IEnumerable<IUserGroup>, IEnumerable<UserGroupBasic>>(Services.UserService.GetAllUserGroups());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all user groups
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public UserGroupDisplay GetUserGroup(int id)
|
||||
{
|
||||
var found = Services.UserService.GetUserGroupById(id);
|
||||
if (found == null)
|
||||
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
|
||||
|
||||
return Mapper.Map<UserGroupDisplay>(found);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -29,10 +29,10 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
public bool HasPublishedVersion { get; set; }
|
||||
|
||||
[DataMember(Name = "owner")]
|
||||
public UserBasic Owner { get; set; }
|
||||
public UserProfile Owner { get; set; }
|
||||
|
||||
[DataMember(Name = "updater")]
|
||||
public UserBasic Updater { get; set; }
|
||||
public UserProfile Updater { get; set; }
|
||||
|
||||
[DataMember(Name = "contentTypeAlias", IsRequired = true)]
|
||||
[Required(AllowEmptyStrings = false)]
|
||||
|
||||
@@ -1,28 +1,51 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
/// <summary>
|
||||
/// A bare minimum structure that represents a user, usually attached to other objects
|
||||
/// </summary>
|
||||
[DataContract(Name = "user", Namespace = "")]
|
||||
public class UserBasic : IComparable
|
||||
[ReadOnly(true)]
|
||||
public class UserBasic : EntityBasic, INotificationModel
|
||||
{
|
||||
[DataMember(Name = "id", IsRequired = true)]
|
||||
[Required]
|
||||
public int UserId { get; set; }
|
||||
|
||||
[DataMember(Name = "name", IsRequired = true)]
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
int IComparable.CompareTo(object obj)
|
||||
public UserBasic()
|
||||
{
|
||||
return String.Compare(Name, ((UserBasic)obj).Name, StringComparison.Ordinal);
|
||||
}
|
||||
Notifications = new List<Notification>();
|
||||
}
|
||||
|
||||
[DataMember(Name = "username")]
|
||||
public string Username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The MD5 lowercase hash of the email which can be used by gravatar
|
||||
/// </summary>
|
||||
[DataMember(Name = "emailHash")]
|
||||
public string EmailHash { get; set; }
|
||||
|
||||
[DataMember(Name = "lastLoginDate")]
|
||||
public DateTime? LastLoginDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of different size avatars
|
||||
/// </summary>
|
||||
[DataMember(Name = "avatars")]
|
||||
public string[] Avatars { get; set; }
|
||||
|
||||
[DataMember(Name = "userState")]
|
||||
public UserState UserState { get; set; }
|
||||
|
||||
[DataMember(Name = "culture", IsRequired = true)]
|
||||
public string Culture { get; set; }
|
||||
|
||||
[DataMember(Name = "email", IsRequired = true)]
|
||||
public string Email { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This is used to add custom localized messages/strings to the response for the app to use for localized UI purposes.
|
||||
/// </summary>
|
||||
[DataMember(Name = "notifications")]
|
||||
public List<Notification> Notifications { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
/// Represents information for the current user
|
||||
/// </summary>
|
||||
[DataContract(Name = "user", Namespace = "")]
|
||||
public class UserDetail : UserBasic
|
||||
public class UserDetail : UserProfile
|
||||
{
|
||||
[DataMember(Name = "email", IsRequired = true)]
|
||||
[Required]
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
@@ -12,45 +10,17 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
/// </summary>
|
||||
[DataContract(Name = "user", Namespace = "")]
|
||||
[ReadOnly(true)]
|
||||
public class UserDisplay : EntityBasic, INotificationModel
|
||||
public class UserDisplay : UserBasic
|
||||
{
|
||||
public UserDisplay()
|
||||
public UserDisplay() : base()
|
||||
{
|
||||
Notifications = new List<Notification>();
|
||||
}
|
||||
|
||||
[DataMember(Name = "username")]
|
||||
public string Username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The MD5 lowercase hash of the email which can be used by gravatar
|
||||
/// </summary>
|
||||
[DataMember(Name = "emailHash")]
|
||||
public string EmailHash { get; set; }
|
||||
|
||||
[DataMember(Name = "lastLoginDate")]
|
||||
public DateTime? LastLoginDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of different size avatars
|
||||
/// </summary>
|
||||
[DataMember(Name = "avatars")]
|
||||
public string[] Avatars { get; set; }
|
||||
|
||||
[DataMember(Name = "userState")]
|
||||
public UserState UserState { get; set; }
|
||||
|
||||
[DataMember(Name = "culture", IsRequired = true)]
|
||||
public string Culture { get; set; }
|
||||
|
||||
[DataMember(Name = "email", IsRequired = true)]
|
||||
public string Email { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of group aliases assigned to the user
|
||||
/// </summary>
|
||||
[DataMember(Name = "userGroups")]
|
||||
public IEnumerable<UserGroupDisplay> UserGroups { get; set; }
|
||||
public IEnumerable<UserGroupBasic> UserGroups { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the available cultures (i.e. to populate a drop down)
|
||||
@@ -70,11 +40,5 @@ namespace Umbraco.Web.Models.ContentEditing
|
||||
///// </summary>
|
||||
//[DataMember(Name = "allowedSections")]
|
||||
//public IEnumerable<string> AllowedSections { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This is used to add custom localized messages/strings to the response for the app to use for localized UI purposes.
|
||||
/// </summary>
|
||||
[DataMember(Name = "notifications")]
|
||||
public List<Notification> Notifications { get; private set; }
|
||||
}
|
||||
}
|
||||
29
src/Umbraco.Web/Models/ContentEditing/UserGroupBasic.cs
Normal file
29
src/Umbraco.Web/Models/ContentEditing/UserGroupBasic.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
[DataContract(Name = "userGroup", Namespace = "")]
|
||||
public class UserGroupBasic : EntityBasic, INotificationModel
|
||||
{
|
||||
public UserGroupBasic()
|
||||
{
|
||||
Notifications = new List<Notification>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used to add custom localized messages/strings to the response for the app to use for localized UI purposes.
|
||||
/// </summary>
|
||||
[DataMember(Name = "notifications")]
|
||||
public List<Notification> Notifications { get; private set; }
|
||||
|
||||
[DataMember(Name = "sections")]
|
||||
public IEnumerable<Section> Sections { get; set; }
|
||||
|
||||
[DataMember(Name = "startContentId")]
|
||||
public EntityBasic StartContentId { get; set; }
|
||||
|
||||
[DataMember(Name = "startMediaId")]
|
||||
public EntityBasic StartMediaId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
[DataContract(Name = "userGroup", Namespace = "")]
|
||||
public class UserGroupDisplay : EntityBasic, INotificationModel
|
||||
public class UserGroupDisplay : UserGroupBasic
|
||||
{
|
||||
public UserGroupDisplay()
|
||||
{
|
||||
Notifications = new List<Notification>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used to add custom localized messages/strings to the response for the app to use for localized UI purposes.
|
||||
/// </summary>
|
||||
[DataMember(Name = "notifications")]
|
||||
public List<Notification> Notifications { get; private set; }
|
||||
|
||||
[DataMember(Name = "sections")]
|
||||
public IEnumerable<Section> Sections { get; set; }
|
||||
|
||||
[DataMember(Name = "startContentId")]
|
||||
public EntityBasic StartContentId { get; set; }
|
||||
|
||||
[DataMember(Name = "startMediaId")]
|
||||
public EntityBasic StartMediaId { get; set; }
|
||||
[DataMember(Name = "users")]
|
||||
public IEnumerable<UserBasic> Users { get; set; }
|
||||
}
|
||||
}
|
||||
28
src/Umbraco.Web/Models/ContentEditing/UserProfile.cs
Normal file
28
src/Umbraco.Web/Models/ContentEditing/UserProfile.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace Umbraco.Web.Models.ContentEditing
|
||||
{
|
||||
/// <summary>
|
||||
/// A bare minimum structure that represents a user, usually attached to other objects
|
||||
/// </summary>
|
||||
[DataContract(Name = "user", Namespace = "")]
|
||||
public class UserProfile : IComparable
|
||||
{
|
||||
[DataMember(Name = "id", IsRequired = true)]
|
||||
[Required]
|
||||
public int UserId { get; set; }
|
||||
|
||||
[DataMember(Name = "name", IsRequired = true)]
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
int IComparable.CompareTo(object obj)
|
||||
{
|
||||
return String.Compare(Name, ((UserProfile)obj).Name, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,18 @@
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using UserProfile = Umbraco.Web.Models.ContentEditing.UserProfile;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Maps the Creator for content
|
||||
/// </summary>
|
||||
internal class CreatorResolver : ValueResolver<IContent, UserBasic>
|
||||
internal class CreatorResolver : ValueResolver<IContent, UserProfile>
|
||||
{
|
||||
protected override UserBasic ResolveCore(IContent source)
|
||||
protected override UserProfile ResolveCore(IContent source)
|
||||
{
|
||||
return Mapper.Map<IProfile, UserBasic>(source.GetWriterProfile());
|
||||
return Mapper.Map<IProfile, UserProfile>(source.GetWriterProfile());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ using System.Linq;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Web.Trees;
|
||||
using UserProfile = Umbraco.Web.Models.ContentEditing.UserProfile;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
@@ -106,7 +107,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(member => member.CreateDate, expression => expression.MapFrom(user => user.CreationDate))
|
||||
.ForMember(member => member.UpdateDate, expression => expression.MapFrom(user => user.LastActivityDate))
|
||||
.ForMember(member => member.Key, expression => expression.MapFrom(user => user.ProviderUserKey.TryConvertTo<Guid>().Result.ToString("N")))
|
||||
.ForMember(member => member.Owner, expression => expression.UseValue(new UserBasic {Name = "Admin", UserId = 0}))
|
||||
.ForMember(member => member.Owner, expression => expression.UseValue(new UserProfile {Name = "Admin", UserId = 0}))
|
||||
.ForMember(member => member.Icon, expression => expression.UseValue("icon-user"))
|
||||
.ForMember(member => member.Name, expression => expression.MapFrom(user => user.UserName))
|
||||
.ForMember(member => member.Email, expression => expression.MapFrom(content => content.Email))
|
||||
|
||||
@@ -3,6 +3,7 @@ using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using UserProfile = Umbraco.Web.Models.ContentEditing.UserProfile;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
@@ -10,12 +11,12 @@ namespace Umbraco.Web.Models.Mapping
|
||||
/// Maps the Owner for IContentBase
|
||||
/// </summary>
|
||||
/// <typeparam name="TPersisted"></typeparam>
|
||||
internal class OwnerResolver<TPersisted> : ValueResolver<TPersisted, UserBasic>
|
||||
internal class OwnerResolver<TPersisted> : ValueResolver<TPersisted, UserProfile>
|
||||
where TPersisted : IContentBase
|
||||
{
|
||||
protected override UserBasic ResolveCore(TPersisted source)
|
||||
protected override UserProfile ResolveCore(TPersisted source)
|
||||
{
|
||||
return Mapper.Map<IProfile, UserBasic>(source.GetCreatorProfile());
|
||||
return Mapper.Map<IProfile, UserProfile>(source.GetCreatorProfile());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,13 +12,15 @@ using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.Models.Identity;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
using UserProfile = Umbraco.Web.Models.ContentEditing.UserProfile;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
internal class UserModelMapper : MapperConfiguration
|
||||
{
|
||||
public override void ConfigureMappings(IConfiguration config, ApplicationContext applicationContext)
|
||||
{
|
||||
{
|
||||
//Used for merging existing UserSave to an existing IUser instance - this will not create an IUser instance!
|
||||
config.CreateMap<UserSave, IUser>()
|
||||
.ForMember(user => user.Language, expression => expression.MapFrom(save => save.Culture))
|
||||
@@ -40,14 +42,14 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(user => user.CreateDate, expression => expression.Ignore())
|
||||
.ForMember(user => user.UpdateDate, expression => expression.Ignore())
|
||||
.AfterMap((save, user) =>
|
||||
{
|
||||
{
|
||||
user.ClearGroups();
|
||||
var foundGroups = applicationContext.Services.UserService.GetUserGroupsByAlias(save.UserGroups.ToArray());
|
||||
foreach (var group in foundGroups)
|
||||
{
|
||||
user.AddGroup(group.ToReadOnlyGroup());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
config.CreateMap<UserInvite, IUser>()
|
||||
.ConstructUsing(invite => new User(invite.Name, invite.Email, invite.Email, Guid.NewGuid().ToString("N")))
|
||||
@@ -86,7 +88,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
}
|
||||
});
|
||||
|
||||
config.CreateMap<IReadOnlyUserGroup, UserGroupDisplay>()
|
||||
config.CreateMap<IReadOnlyUserGroup, UserGroupBasic>()
|
||||
.ForMember(detail => detail.StartContentId, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.StartMediaId, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Key, opt => opt.Ignore())
|
||||
@@ -99,18 +101,10 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(detail => detail.AdditionalData, opt => opt.Ignore())
|
||||
.AfterMap((group, display) =>
|
||||
{
|
||||
var allSections = applicationContext.Services.SectionService.GetSections();
|
||||
display.Sections = allSections.Where(x => group.Alias == x.Alias).Select(Mapper.Map<ContentEditing.Section>);
|
||||
MapUserGroupBasic(applicationContext.Services, group, display);
|
||||
});
|
||||
|
||||
//applicationContext.Services.EntityService.Get<IContent>(x.StartContentId, false))
|
||||
//applicationContext.Services.EntityService.Get<IMedia>(x.StartMediaId, false))
|
||||
if (display.Icon.IsNullOrWhiteSpace())
|
||||
{
|
||||
display.Icon = "icon-users";
|
||||
}
|
||||
});
|
||||
|
||||
config.CreateMap<IUserGroup, UserGroupDisplay>()
|
||||
config.CreateMap<IUserGroup, UserGroupBasic>()
|
||||
.ForMember(detail => detail.StartContentId, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.StartMediaId, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Sections, opt => opt.Ignore())
|
||||
@@ -122,12 +116,25 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(detail => detail.AdditionalData, opt => opt.Ignore())
|
||||
.AfterMap((group, display) =>
|
||||
{
|
||||
var allSections = applicationContext.Services.SectionService.GetSections();
|
||||
display.Sections = allSections.Where(x => group.Alias == x.Alias).Select(Mapper.Map<ContentEditing.Section>);
|
||||
|
||||
//applicationContext.Services.EntityService.Get<IContent>(x.StartContentId, false))
|
||||
//applicationContext.Services.EntityService.Get<IMedia>(x.StartMediaId, false))
|
||||
MapUserGroupBasic(applicationContext.Services, group, display);
|
||||
});
|
||||
|
||||
config.CreateMap<IUserGroup, UserGroupDisplay>()
|
||||
.ForMember(detail => detail.StartContentId, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.StartMediaId, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Sections, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Notifications, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Udi, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Trashed, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.ParentId, opt => opt.UseValue(-1))
|
||||
.ForMember(detail => detail.Path, opt => opt.MapFrom(userGroup => "-1," + userGroup.Id))
|
||||
.ForMember(detail => detail.AdditionalData, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Users, opt => opt.Ignore())
|
||||
.AfterMap((group, display) =>
|
||||
{
|
||||
MapUserGroupBasic(applicationContext.Services, group, display);
|
||||
var users = applicationContext.Services.UserService.GetAllInGroup(group.Id);
|
||||
display.Users = Mapper.Map<IEnumerable<UserBasic>>(users);
|
||||
});
|
||||
|
||||
config.CreateMap<IUser, UserDisplay>()
|
||||
@@ -165,11 +172,29 @@ namespace Umbraco.Web.Models.Mapping
|
||||
if (startMediaIds.Length > 0)
|
||||
{
|
||||
var mediaItems = applicationContext.Services.EntityService.GetAll(UmbracoObjectTypes.Document, startMediaIds);
|
||||
display.StartMediaIds = Mapper.Map<IEnumerable<IUmbracoEntity>, IEnumerable<EntityBasic>>(mediaItems);
|
||||
display.StartMediaIds = Mapper.Map<IEnumerable<IUmbracoEntity>, IEnumerable<EntityBasic>>(mediaItems);
|
||||
}
|
||||
display.UserGroups = Mapper.Map<IEnumerable<IReadOnlyUserGroup>, IEnumerable<UserGroupDisplay>>(user.Groups);
|
||||
display.UserGroups = Mapper.Map<IEnumerable<IReadOnlyUserGroup>, IEnumerable<UserGroupBasic>>(user.Groups);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
config.CreateMap<IUser, UserBasic>()
|
||||
.ForMember(detail => detail.Avatars, opt => opt.MapFrom(user => user.GetCurrentUserAvatarUrls(applicationContext.Services.UserService, applicationContext.ApplicationCache.RuntimeCache)))
|
||||
.ForMember(detail => detail.Username, opt => opt.MapFrom(user => user.Username))
|
||||
.ForMember(detail => detail.LastLoginDate, opt => opt.MapFrom(user => user.LastLoginDate == default(DateTime) ? null : (DateTime?) user.LastLoginDate))
|
||||
.ForMember(detail => detail.Culture, opt => opt.MapFrom(user => user.GetUserCulture(applicationContext.Services.TextService)))
|
||||
.ForMember(
|
||||
detail => detail.EmailHash,
|
||||
opt => opt.MapFrom(user => user.Email.ToLowerInvariant().Trim().ToMd5()))
|
||||
.ForMember(detail => detail.ParentId, opt => opt.UseValue(-1))
|
||||
.ForMember(detail => detail.Path, opt => opt.MapFrom(user => "-1," + user.Id))
|
||||
.ForMember(detail => detail.Notifications, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Udi, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Icon, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Trashed, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Alias, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.Trashed, opt => opt.Ignore())
|
||||
.ForMember(detail => detail.AdditionalData, opt => opt.Ignore());
|
||||
|
||||
config.CreateMap<IUser, UserDetail>()
|
||||
.ForMember(detail => detail.Avatars, opt => opt.MapFrom(user => user.GetCurrentUserAvatarUrls(applicationContext.Services.UserService, applicationContext.ApplicationCache.RuntimeCache)))
|
||||
@@ -182,7 +207,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
opt => opt.MapFrom(user => user.Email.ToLowerInvariant().Trim().ToMd5()))
|
||||
.ForMember(detail => detail.SecondsUntilTimeout, opt => opt.Ignore());
|
||||
|
||||
config.CreateMap<IProfile, UserBasic>()
|
||||
config.CreateMap<IProfile, UserProfile>()
|
||||
.ForMember(detail => detail.UserId, opt => opt.MapFrom(profile => GetIntId(profile.Id)));
|
||||
|
||||
config.CreateMap<IUser, UserData>()
|
||||
@@ -197,8 +222,28 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(detail => detail.Culture, opt => opt.MapFrom(user => user.GetUserCulture(applicationContext.Services.TextService)))
|
||||
.ForMember(detail => detail.SessionId, opt => opt.MapFrom(user => user.SecurityStamp.IsNullOrWhiteSpace() ? Guid.NewGuid().ToString("N") : user.SecurityStamp));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void MapUserGroupBasic(ServiceContext services, dynamic group, UserGroupBasic display)
|
||||
{
|
||||
var allSections = services.SectionService.GetSections();
|
||||
display.Sections = allSections.Where(x => group.Alias == x.Alias).Select(Mapper.Map<ContentEditing.Section>);
|
||||
if (group.StartMediaId > 0)
|
||||
{
|
||||
display.StartMediaId = Mapper.Map<EntityBasic>(
|
||||
services.EntityService.Get<IMedia>(group.StartMediaId, false));
|
||||
}
|
||||
if (group.StartContentId > 0)
|
||||
{
|
||||
display.StartContentId = Mapper.Map<EntityBasic>(
|
||||
services.EntityService.Get<IContent>(group.StartContentId, false));
|
||||
}
|
||||
if (display.Icon.IsNullOrWhiteSpace())
|
||||
{
|
||||
display.Icon = "icon-users";
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetIntId(object id)
|
||||
{
|
||||
var result = id.TryConvertTo<int>();
|
||||
|
||||
@@ -388,6 +388,8 @@
|
||||
<Compile Include="Models\ContentEditing\SnippetDisplay.cs" />
|
||||
<Compile Include="Models\ContentEditing\TemplateDisplay.cs" />
|
||||
<Compile Include="Models\ContentEditing\UserDisplay.cs" />
|
||||
<Compile Include="Models\ContentEditing\UserBasic.cs" />
|
||||
<Compile Include="Models\ContentEditing\UserGroupBasic.cs" />
|
||||
<Compile Include="Models\ContentEditing\UserGroupDisplay.cs" />
|
||||
<Compile Include="Models\DetachedPublishedContent.cs" />
|
||||
<Compile Include="Models\DetachedPublishedProperty.cs" />
|
||||
@@ -836,7 +838,7 @@
|
||||
<Compile Include="Models\ContentEditing\Section.cs" />
|
||||
<Compile Include="Models\ContentEditing\Tab.cs" />
|
||||
<Compile Include="Models\ContentEditing\TabbedContentItem.cs" />
|
||||
<Compile Include="Models\ContentEditing\UserBasic.cs" />
|
||||
<Compile Include="Models\ContentEditing\UserProfile.cs" />
|
||||
<Compile Include="Models\ContentEditing\UserDetail.cs" />
|
||||
<Compile Include="FormDataCollectionExtensions.cs" />
|
||||
<Compile Include="Models\Mapping\ContentPropertyBasicConverter.cs" />
|
||||
|
||||
Reference in New Issue
Block a user