Beispiel #1
0
        public async Task <JsonResult> GetProfile(Guid ChatroomGuid)
        {
            var GetTypeResult = await _chatroomsFacad.GetChatroomTypeByGuidService.ExecuteAsync(ChatroomGuid);

            if (GetTypeResult.Status == ServiceStatus.Success)
            {
                var MyUserId = User.GetUserId();


                if (GetTypeResult.Data == ChatroomType.PV)
                {
                    #region Return User Profile
                    var GetUserIdResult = await _chatroomsFacad.GetUserIdByPVGuidService.ExecuteAsync(MyUserId, ChatroomGuid);

                    var result = await _usersFacad.GetUserPublicProfileByUserIdService.ExecuteAsync(GetUserIdResult.Data);

                    UserPublicProfileViewModel Data = new UserPublicProfileViewModel()
                    {
                        Bio         = result.Data.Bio,
                        ImageName   = result.Data.ImageName,
                        Name        = result.Data.Name,
                        UserHaskKey = result.Data.UserHaskKey,
                        Username    = result.Data.Username,
                    };

                    return(Json(new { Data = Data, type = GetTypeResult.Data, Status = result.Status, Guid = ChatroomGuid }));

                    #endregion
                }
                else
                {
                    #region Return Group Profile
                    var result = await _chatroomsFacad.GetGroupDetailForProfileService.ExecuteAsync(MyUserId, ChatroomGuid);

                    GroupDetailForProfileViewModel Data = new GroupDetailForProfileViewModel()
                    {
                        GroupName = result.Data.GroupName,
                        ImageName = result.Data.ImageName,
                        MyLevel   = result.Data.MyLevel,
                        Members   = result.Data.Members.Select(m => new GroupMemberViewModel()
                        {
                            HashKey     = m.HashKey,
                            MemberLevel = m.MemberLevel,
                            ImageName   = m.ImageName,
                            Name        = m.Name,
                        }),
                    };

                    return(Json(new { Data = Data, type = GetTypeResult.Data, Status = result.Status, Guid = ChatroomGuid }));

                    #endregion
                }
            }

            return(Json(GetTypeResult));
        }
Beispiel #2
0
        private UserPublicProfileViewModel ProjectToViewModel(UserPublicProfile model)
        {
            var viewModel = new UserPublicProfileViewModel
            {
                Id            = model.Id,
                DisplayName   = model.DisplayName,
                ChannelsCount = model.ChannelsCount
            };

            return(viewModel);
        }