private async void InitializeContent(User user)
        {
            Debug.WriteLine("\n\n\n ===================>>>> STARTED LOADING USER DATA");
            await LoadUserData(user);
            Debug.WriteLine("===================>>>> FINISHED LOADING USER DATA \n\n\n ");

            await LoadConversations();
        }
 private async Task LoadUserData(User user)
 {
     ActiveUser = await _userDao.Get(user.Username);
 }
 public ChatWindow(User user)
 {
     InitializeComponent();
     InitializeContent(user);
 }
        /// <summary>
        /// Creates conversation with user entered in the textbox. 
        /// Because of that, conversation is currently possible only between 2 users.
        /// </summary>
        private async void AddConversationButton_Click(object sender, RoutedEventArgs e)
        {
            User newContact = new User();
            newContact.Username = AddConversationTextBox.Text;
            if (!await _userDao.Exists(newContact))
            {
                ErrorLabel.Content = "Contact with that username doesn't exist!";
                return;
            }
            newContact = await _userDao.Get(newContact.Username);
            
            Conversation newConversation = new Conversation();
            newConversation.Participants.Add(ActiveUser);
            newConversation.Participants.Add(newContact);

            if (await _conversationDao.Exists(newConversation))
            {
                ErrorLabel.Content = "That conversation already exists!";
            }
            else
            {
                newConversation.Id = await _conversationDao.Add(newConversation);

                ActiveUser.Conversations.Add(newConversation);
                await _userDao.Update(ActiveUser);

                newContact.Conversations.Add(newConversation);
                await _userDao.Update(newContact);

                //ActiveUser.ConversationIdList.Add(newConversation.Id);
                //await _userDao.Update(ActiveUser);

                //newContact.ConversationIdList.Add(newConversation.Id);
                //await _userDao.Update(newContact);

                _conversationCollection.Add(newConversation);
                CollectionView view =
                    (CollectionView) CollectionViewSource.GetDefaultView(ConversationListView.ItemsSource);
                view.Refresh();
            }
        }
 public async Task<bool> Exists(User user)
 {
     IHubProxy hubProxy = await DBConnection.GetProxy(hubName);
     return await hubProxy.Invoke<bool>("Exists", user);
 }
 public async Task<bool> ValidateCredentials(User user, string password)
 {
     IHubProxy hubProxy = await DBConnection.GetProxy(hubName);
     return await hubProxy.Invoke<bool>("ValidateCredentials", user, password);
 }
 public async Task<bool> Add(User user, string password)
 {
     IHubProxy hubProxy = await DBConnection.GetProxy(hubName);
     return await hubProxy.Invoke<bool>("Add", user, password);
 }