コード例 #1
0
        public void InitializedChatsPage(SavedChats savedChats)
        {
            try
            {
                if (savedChats.SavedPrivateChats != null)
                {
                    ChatList = new ObservableCollection <PrivateChat>(savedChats.SavedPrivateChats);
                }


                ChatList.Add(new PrivateChat {
                    Name = "Олександр Журба"
                });
                ChatList.Add(new PrivateChat {
                    Name = "Fedir Khydzik"
                });
                ChatList.Add(new PrivateChat {
                    Name = "Olya Ivanenko"
                });
                ChatList.Add(new PrivateChat {
                    Name = "Віталій Пилипенко"
                });
                ChatList.Add(new PrivateChat {
                    Name = "Іван Пилипенко"
                });
                ChatList.Add(new PrivateChat {
                    Name = "Volodya Ivan"
                });
            }
            catch (Exception) { return; }
        }
コード例 #2
0
        public async Task <SavedChats> GetHistoryChatsAsync(Guid userId)
        {
            var firstUserChats = await _chatRepository.Query().Where(r => r.FirstUserInfoId == userId).ToListAsync();

            var secondUserChats = await _chatRepository.Query().Where(r => r.SecondUserInfoId == userId).ToListAsync();

            var chats = new SavedChats {
                UserId = userId
            };

            foreach (var value in firstUserChats)
            {
                chats.SavedPrivateChats.Add(new PrivateChat
                {
                    Id            = value.Id,
                    Name          = value.SecondUserInfo.LastName + " " + value.SecondUserInfo.FirstName,
                    OwnUserId     = new Guid(value.FirstUserInfo.Id),
                    UserIdToWrite = new Guid(value.SecondUserInfo.Id)
                });
            }

            foreach (var value in secondUserChats)
            {
                chats.SavedPrivateChats.Add(new PrivateChat
                {
                    Id            = value.Id,
                    Name          = value.FirstUserInfo.LastName + " " + value.FirstUserInfo.FirstName,
                    UserIdToWrite = new Guid(value.FirstUserInfo.Id),
                    OwnUserId     = new Guid(value.SecondUserInfo.Id)
                });
            }

            return(chats);
        }
コード例 #3
0
        public ChatPageViewModel(SavedChats savedChats, UsersInfoModel usersInfoModel)
        {
            SelectMessageCommand = new DelegateCommand <PrivateChat>(SelectChat);
            SendNewMessage       = new DelegateCommand(SendMessage);

            Name = usersInfoModel.FullName;
            _connectionManager = new ConnectionManager();
            WriteManId         = usersInfoModel.Id;
            InitializedChatsPage(savedChats);
            UserID               = savedChats.UserId;
            CurrentChat          = savedChats.SavedPrivateChats.SingleOrDefault(chat => chat.UserIdToWrite.ToString() == usersInfoModel.Id);
            CurrentChat.Messages = new ObservableCollection <ChatMessage>();
        }
コード例 #4
0
        public ChatPage(SavedChats savedChats, UsersInfoModel usersInfoModel)
        {
            InitializeComponent();

            DataContext = new ChatPageViewModel(savedChats, usersInfoModel);
        }
コード例 #5
0
 public async Task <SavedChats> HistoryChatsAsync([FromBody] SavedChats input)
 {
     return(await _userService.GetHistoryChatsAsync(input.UserId));
 }