// This file was generated automatically by Qleany's generator, edit at your own risk! 
// If you do, be careful to not overwrite it when you run the generator again.
#pragma once
#include "{{ interactor.feature_snake_name }}/{{ interactor.feature_snake_name }}_interactor.h"
#include <QCoroQml>
#include <QCoroQmlTask>
#include <QQmlEngine>


using namespace {{ application_cpp_domain_name }}::Interactor::{{ interactor.feature_pascal_name }};

class Foreign{{ interactor.feature_pascal_name }}Interactor : public QObject
{
    Q_OBJECT
    QML_SINGLETON
    QML_NAMED_ELEMENT({{ interactor.feature_pascal_name }}Interactor)

public:

    Foreign{{ interactor.feature_pascal_name }}Interactor(QObject *parent = nullptr) : QObject(parent)
    {
        s_interactorInstance = {{ interactor.feature_pascal_name }}Interactor::instance();
    }

{% if interactor.crud.enabled %}
    {%if interactor.crud.get %}
    Q_INVOKABLE QCoro::QmlTask get(int id) const
    {
        return s_interactorInstance->get(id);
    }
    {% endif %}

    {%if interactor.crud.get_with_details %}
    Q_INVOKABLE QCoro::QmlTask getWithDetails(int id) const
    {
        return s_interactorInstance->get(id);
    }
    {% endif %}

    {%if interactor.crud.get_all %}
    Q_INVOKABLE QCoro::QmlTask getAll() const
    {
        return s_interactorInstance->getAll();
    }
    {% endif %}

    {%if interactor.crud.create %}
    Q_INVOKABLE Create{{ interactor.feature_pascal_name }}DTO getCreateDTO()
    {
        return s_interactorInstance->getCreateDTO();
    }
    {% endif %}

    {%if interactor.crud.update_ %}
    Q_INVOKABLE Update{{ interactor.feature_pascal_name }}DTO getUpdateDTO()
    {
        return s_interactorInstance->getUpdateDTO();
    }
    {% endif %}
{% endif %}

    {% for query in interactor.custom_queries %}
    Q_INVOKABLE QCoro::QmlTask {{ query.camel_name }}({% if query.dto_in_enabled %}{{ query.dto_in_pascal_type_prefix }}DTO dto{% endif %}) const
    {
        return s_interactorInstance->{{ query.camel_name }}({% if query.dto_in_enabled %}dto{% endif %});
    }
    
    {%if query.dto_in_enabled %}
    Q_INVOKABLE {{ query.dto_in_pascal_type_prefix }}DTO get{{ query.dto_in_pascal_type_prefix }}DTO()
    {
        return {{ query.dto_in_pascal_type_prefix }}DTO();
    }
    {% endif %}

    {% endfor %}

{% if interactor.crud.enabled %}
    {% if interactor.crud.create %}

    Q_INVOKABLE QCoro::QmlTask create(const Create{{ interactor.feature_pascal_name }}DTO &dto)
    {
        return s_interactorInstance->create(dto);
    }
    {% endif %}

    {% if interactor.crud.update_ %}
    Q_INVOKABLE QCoro::QmlTask update(const Update{{ interactor.feature_pascal_name }}DTO &dto)
    {
        return s_interactorInstance->update(dto);
    }
    {% endif %}

    {%if interactor.crud.remove %}
    Q_INVOKABLE QCoro::QmlTask remove(int id)
    {
        return s_interactorInstance->remove(id);
    }
    {% endif %}
{% endif %}

    {% for command in interactor.custom_commands %}
    Q_INVOKABLE QCoro::QmlTask {{ command.camel_name }}({% if command.dto_in_enabled %}{{ command.dto_in_pascal_type_prefix }}DTO dto{% endif %})
    {
        return s_interactorInstance->{{ command.camel_name }}({% if command.dto_in_enabled %}dto{% endif %});
    }

    {%if command.dto_in_enabled %}
    Q_INVOKABLE {{ command.dto_in_pascal_type_prefix }}DTO get{{ command.dto_in_pascal_type_prefix }}DTO()
    {
        return {{ command.dto_in_pascal_type_prefix }}DTO();
    }
    {% endif %}

    {% endfor %}


private:

    {{ interactor.feature_pascal_name }}Interactor *s_interactorInstance = nullptr;
};
