#pragma once

#include "../databasemanager.h"
#include <QVector>
#include <optional>
#include "common_structs.h"

class RuleDao
{
public:
    static bool insert(Rule& rule);
    static bool update(const Rule& rule);
    static bool remove(qint64 id);
    static std::optional<Rule> findById(qint64 id);
    static QVector<Rule> findByAccount(qint64 accountId);  // accountId = -1 for global
    static QVector<Rule> findGlobal();
    static QVector<Rule> findAll();
    static QVector<Rule> findAllEnabled();  // only enabled rules
    static bool setEnabled(qint64 id, bool enabled);
    static bool updateLastRun(qint64 id, const QDateTime& when, qint64 runCount);
};