Exemplo n.º 1
0
        public static void removeUser(string password)
        {
            using (NpgsqlConnection con = new NpgsqlConnection(DBConnection.connString))
            {
                using (NpgsqlCommand command = new NpgsqlCommand())
                {
                    try
                    {
                        verifyUser(nickName, password);

                        con.Open();
                        var transaction = con.BeginTransaction();
                        command.Connection  = con;
                        command.Transaction = transaction;
                        command.CommandText = string.Concat("DELETE FROM users WHERE (id = '", id, "');");
                        command.ExecuteNonQuery();
                        command.CommandText = string.Concat("DELETE FROM passwords WHERE (user_id = '", id, "');");
                        command.ExecuteNonQuery();

                        nickName = null;
                        id       = null;
                        instance = null;

                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        throw;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static void removeIngredient(string name)
        {
            using (NpgsqlConnection con = new NpgsqlConnection(DBConnection.connString))
            {
                using (NpgsqlCommand command = new NpgsqlCommand())
                {
                    try
                    {
                        con.Open();
                        var transaction = con.BeginTransaction();
                        command.Connection  = con;
                        command.Transaction = transaction;
                        command.CommandText = string.Concat("DELETE FROM ingredients WHERE (name = '", name, "' AND user_id = '", id, "');");
                        command.ExecuteNonQuery();

                        nickName = null;
                        id       = null;
                        instance = null;

                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        throw;
                    }
                }
            }
        }
Exemplo n.º 3
0
 public dbRequestsHandler createInstance(string name, string password)
 {
     verifyUser(name, password);
     if (instance == null)
     {
         instance = new dbRequestsHandler(name);
         return(instance);
     }
     else
     {
         return(instance);
     }
 }