Exemple #1
0
        public void friendBtnClick(object sender, EventArgs e)
        {
            if ((sender as Button).Text == "Añadir amigo")
            {
                bool check = _proxy.CreateFriendRequest(Convert.ToInt32((sender as Button).Name), _userID);

                if (check)
                {
                    _form.Hide();
                    Form next = new OtherProfile(Convert.ToInt32((sender as Button).Name));
                    next.ShowDialog();
                    _form.Close();
                }
                else
                {
                    MessageBox.Show("Error al mandar solicitud.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if ((sender as Button).Text == "Eliminar amigo")
            {
                User otherUser = _proxy.GetUserById(Convert.ToInt32((sender as Button).Name));
                if (MessageBox.Show($"¿Seguro que quieres eliminar a {otherUser.firstName}?", "Eliminar amigo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    bool check = _proxy.DeleteFriendship(_userID, otherUser.ID);

                    if (check)
                    {
                        _form.Hide();
                        Form next = new OtherProfile(otherUser.ID);
                        next.ShowDialog();
                        _form.Close();
                    }
                    else
                    {
                        MessageBox.Show("Error al eliminar amigo.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                User otherUser = _proxy.GetUserById(Convert.ToInt32((sender as Button).Name));
                if (MessageBox.Show($"¿Seguro que quieres cancelar la solicitud de amistad a {otherUser.firstName}?", "Cancelar solicitud", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    bool check = _proxy.DeleteFriendshipRequest(otherUser.ID, _userID);

                    if (check)
                    {
                        _form.Hide();
                        Form next = new FriendSearch(_pattern);
                        next.ShowDialog();
                        _form.Close();
                    }
                    else
                    {
                        MessageBox.Show("Error al eliminar solicitud.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
        public void rejectBtnClick(object sender, EventArgs e)
        {
            bool check = _proxy.DeleteFriendshipRequest(_userID, Convert.ToInt32((sender as Button).Name));

            if (check)
            {
                _form.Hide();
                Form next = new FriendRequest();
                next.ShowDialog();
                _form.Close();
            }
            else
            {
                MessageBox.Show("Error al rechazar amigo.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
        private void friendsBtn_Click(object sender, EventArgs e)
        {
            if (friendsBtn.Text == "Aceptar solicitud")
            {
                bool check = proxy.CreateFriendship(user.ID, otherUser.ID);

                if (check)
                {
                    friendsBtn.Text = "Eliminar amigo";
                }
                else
                {
                    MessageBox.Show("Error al agregar amigo.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (friendsBtn.Text == "Eliminar amigo")
            {
                if (MessageBox.Show($"¿Seguro que quieres eliminar a {otherUser.firstName}?", "Eliminar amigo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    bool check = proxy.DeleteFriendship(user.ID, otherUser.ID);

                    if (check)
                    {
                        friendsBtn.Text = "Añadir amigo";
                    }
                    else
                    {
                        MessageBox.Show("Error al eliminar amigo.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else if (friendsBtn.Text == "Añadir amigo")
            {
                bool check = proxy.CreateFriendRequest(otherUser.ID, user.ID);

                if (check)
                {
                    friendsBtn.Text = "Cancelar solicitud";
                }
                else
                {
                    MessageBox.Show("Error al mandar solicitud.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                if (MessageBox.Show($"¿Seguro que quieres cancelar la solicitud de amistad a {otherUser.firstName}?", "Cancelar solicitud", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    bool check = proxy.DeleteFriendshipRequest(otherUser.ID, user.ID);

                    if (check)
                    {
                        friendsBtn.Text = "Añadir amigo";
                    }
                    else
                    {
                        MessageBox.Show("Error al eliminar solicitud.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }