Exemplo n.º 1
0
        public UserProfileDto GetProfileDetails(string userProfileId)
        {
            var user = string.IsNullOrEmpty(userProfileId)
                ? userHelper.GetUserById(userHelper.GetCurrentLoggedUserId())
                : userHelper.GetUserByName(userProfileId);

            var userIdentificator = new Guid(user.Id);
            var userInfo          = db.UserProfileInfo.Find(userIdentificator);
            var userProfile       = new UserProfileDto();

            userProfile.UserId           = new Guid(user.Id);
            userProfile.UserName         = user.UserName;
            userProfile.DateOfCreation   = userInfo.DateOfCreation.Value.ToShortDateString();
            userProfile.IsBlocked        = userInfo.IsBlocked;
            userProfile.Roles            = userHelper.GetRoleNamesByUserId(userIdentificator);
            userProfile.UserMail         = user.Email;
            userProfile.AvatarExists     = userInfo.Avatar != null;
            userProfile.AccountConfirmed = user.EmailConfirmed;
            userProfile.IsOwnAccount     = string.IsNullOrEmpty(userProfileId) ||
                                           userHelper.IsSameUserScreen(userIdentificator);
            userProfile.RolesList     = userHelper.GetRolesToCombo();
            userProfile.CommentsCount = articleHelper.GetCommentsByUser(userIdentificator).Count;

            return(userProfile);
        }