Esempio n. 1
0
        public Connections()
        {
            InitializeComponent();


            ChatRoomWindow chatr = new ChatRoomWindow();

            sender_name.Text = chatr.username;

            using (ChatDb l = new ChatDb())
            {
                ChatRoom chat = new ChatRoom() /* Senders = s, Recievers = c.Messages.Select(d => d.Recievers.First()).ToList() */ }
                {
                    ;
                    Reciever r = new Reciever()
                    {
                        Chat = chat, Users = l.Users.Where(y => y.Login == chatr.username).ToList()
                    };
                    Sender s = new Sender()
                    {
                        Chat = chat, Users = l.Users.Where(j => j.Id == 15).ToList()
                    };
                    l.Senders.Add(s);
                    l.Recievers.Add(r);
                    l.ChatRooms.Add(chat);
                    l.SaveChanges();

                    sender_img.Source = new BitmapImage(new Uri(l.Users.Where(n => n.Id == 15).Single().UserPhotoPath.ToString()));//   .Select(j => j.UserPhotoPath).ToString()));
                    // reciever_img.Source = new BitmapImage(new Uri(l.Users.Where(v=>v.Login==chatr.username).Single().UserPhotoPath.ToString()));
            }
        }
 private void Btn_save_Click(object sender, RoutedEventArgs e)
 {
     if (!String.IsNullOrEmpty(btn_save.Content.ToString()))
     {
         User u = new User()
         {
             Login = tb_login.Text, Password = tb_password.Text, UserPhotoPath = tb_img.Text
         };
         MainUser = u;
         using (ChatDb c = new ChatDb())
         {
             c.Users.Add(u);
             c.SaveChanges();
         }
         //this.DialogResult = true;
         ChatRoomWindow chatRoomWindow = new ChatRoomWindow();
         chatRoomWindow.Show();
     }
 }