Exemplo n.º 1
0
        private void Send_button_Click(object sender, RoutedEventArgs e)
        {
            var context = new MyFitEntities();

            var newFriend = new FriendRequest()
            {
                fromUsername = myusername_textbox.Text,
                toUsername   = ToUsername_textbox.Text,
            };

            context.FriendRequests.Add(newFriend);
            context.SaveChanges();
            this.Close();
        }
Exemplo n.º 2
0
        private void Delete_button_Clicked(object sender, RoutedEventArgs e)
        {
            var selectedRow = friendRequestViewSource.View.CurrentItem as FriendRequest;


            FriendRequest currentRequest = (from c in context.FriendRequests
                                            where c.id_FriendRequest == selectedRow.id_FriendRequest
                                            select c).SingleOrDefault();

            if (currentRequest != null)
            {
                context.FriendRequests.Remove(currentRequest);
                context.SaveChanges();
            }

            friendRequestViewSource.View.Refresh();
        }
Exemplo n.º 3
0
        private void addfriend_button_Click(object sender, RoutedEventArgs e)
        {
            var context = new MyFitEntities();

            var check = (from c in context.AccountCredentials where c.AccEmail == friend1_textbox.Text select c).FirstOrDefault();

            if (check == null)
            {
                MessageBox.Show($"Your friend with this email {friend1_textbox.Text} doesn't have an account! Please invite him to join us and then add him/her as a friend!");
            }
            else
            {
                var friend1 = new FriendRequest()
                {
                    fromUsername = NewAccountWindow1.currentUsername,
                    toUsername   = friend1_textbox.Text,
                };

                context.FriendRequests.Add(friend1);
                context.SaveChanges();
            }

            var check2 = (from c in context.AccountCredentials where c.AccEmail == friend2_textbox.Text select c).FirstOrDefault();

            if (check2 == null)
            {
                MessageBox.Show($"Your friend with this email {friend2_textbox.Text} doesn't have an account! Please invite him to join us and then add him/her as a friend!");
            }
            else
            {
                var friend2 = new FriendRequest()
                {
                    fromUsername = NewAccountWindow1.currentUsername,
                    toUsername   = friend2_textbox.Text,
                };

                context.FriendRequests.Add(friend2);
                context.SaveChanges();
            };



            var check3 = (from c in context.AccountCredentials where c.AccEmail == friend3_textbox.Text select c).FirstOrDefault();

            if (check3 == null)
            {
                MessageBox.Show($"Your friend with this email {friend3_textbox.Text} doesn't have an account! Please invite him to join us and then add him/her as a friend!");
            }
            else
            {
                var friend3 = new FriendRequest()
                {
                    fromUsername = NewAccountWindow1.currentUsername,
                    toUsername   = friend3_textbox.Text,
                };

                context.FriendRequests.Add(friend3);
                context.SaveChanges();
            }
            this.Close();
        }