2019-05-22 09:28:34 +00:00
|
|
|
|
using System;
|
|
|
|
|
using ASC.Core;
|
|
|
|
|
using ASC.Core.Users;
|
2019-06-07 11:34:09 +00:00
|
|
|
|
using ASC.Web.Core.Users;
|
|
|
|
|
using ASC.Web.Studio.Utility;
|
2019-05-22 09:28:34 +00:00
|
|
|
|
|
|
|
|
|
namespace ASC.Web.Api.Models
|
|
|
|
|
{
|
|
|
|
|
public class EmployeeWraper
|
|
|
|
|
{
|
|
|
|
|
protected EmployeeWraper()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public EmployeeWraper(UserInfo userInfo)
|
|
|
|
|
{
|
|
|
|
|
Id = userInfo.ID;
|
2019-06-07 11:34:09 +00:00
|
|
|
|
DisplayName = DisplayUserSettings.GetFullUserName(userInfo);
|
2019-05-22 09:28:34 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(userInfo.Title))
|
|
|
|
|
{
|
|
|
|
|
Title = userInfo.Title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//if (EmployeeWraperFull.CheckContext(context, "avatarSmall"))
|
|
|
|
|
//{
|
2019-06-07 11:34:09 +00:00
|
|
|
|
AvatarSmall = UserPhotoManager.GetSmallPhotoURL(userInfo.ID) + "?_=" + userInfo.LastModified.GetHashCode();
|
2019-05-22 09:28:34 +00:00
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Guid Id { get; set; }
|
|
|
|
|
|
|
|
|
|
public string DisplayName { get; set; }
|
|
|
|
|
|
|
|
|
|
public string Title { get; set; }
|
|
|
|
|
|
|
|
|
|
public string AvatarSmall { get; set; }
|
|
|
|
|
|
|
|
|
|
public string ProfileUrl
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2019-06-07 11:34:09 +00:00
|
|
|
|
if (Id == Guid.Empty) return string.Empty;
|
|
|
|
|
var profileUrl = CommonLinkUtility.GetUserProfile(Id.ToString(), false);
|
|
|
|
|
return profileUrl;
|
2019-05-22 09:28:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static EmployeeWraper Get(Guid userId)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return Get(CoreContext.UserManager.GetUsers(userId));
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
return Get(Constants.LostUser);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static EmployeeWraper Get(UserInfo userInfo)
|
|
|
|
|
{
|
|
|
|
|
return new EmployeeWraper(userInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static EmployeeWraper GetSample()
|
|
|
|
|
{
|
|
|
|
|
return new EmployeeWraper
|
|
|
|
|
{
|
|
|
|
|
Id = Guid.Empty,
|
|
|
|
|
DisplayName = "Mike Zanyatski",
|
|
|
|
|
Title = "Manager",
|
|
|
|
|
AvatarSmall = "url to small avatar",
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|