Exemple #1
0
        ObservableCollection <ChatModel> GetChatsByUser(UserModel user)
        {
            ObservableCollection <ChatModel> chats = new ObservableCollection <ChatModel>();

            using (MainDataBase dataBase = new MainDataBase())
            {
                chatUserRepository = new ChatUserRepository(dataBase);
                chatRepository     = new ChatsRepository(dataBase);

                foreach (ChatUserModel chatUserModel in chatUserRepository.GetAll(i => i.UserId == user.Id))
                {
                    chats.Add(chatRepository.GetById((int)chatUserModel.ChatId));
                }
            }
            return(chats);
        }
Exemple #2
0
        List <UserModel> GetUsersByChat(ChatModel chat)
        {
            List <UserModel> users = new List <UserModel>();

            using (MainDataBase dataBase = new MainDataBase())
            {
                chatUserRepository = new ChatUserRepository(dataBase);
                usersRepository    = new UsersRepository(dataBase);

                foreach (ChatUserModel chatUserModel in chatUserRepository.GetAll(i => i.ChatId == chat.Id))
                {
                    users.Add(usersRepository.GetById((int)chatUserModel.UserId));
                }
            }
            return(users);
        }
Exemple #3
0
        List <UserModel> GetRestUsers()
        {
            List <UserModel> restUsers = new List <UserModel>();

            using (MainDataBase dataBase = new MainDataBase())
            {
                chatUserRepository = new ChatUserRepository(dataBase);
                usersRepository    = new UsersRepository(dataBase);

                _givenUsers = new ObservableCollection <UserModel>();

                List <ChatUserModel> chatUsers = chatUserRepository.GetAll(i => i.ChatId == _chat.Id);

                foreach (ChatUserModel chatUser in chatUsers)
                {
                    _givenUsers.Add(usersRepository.GetById((int)chatUser.UserId));
                }

                return(restUsers = usersRepository.GetAll().Except(_givenUsers).ToList());
            }
        }