// 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 "{{ export_header }}"
#include "{{ feature_snake_name }}/{{ query.dto_out_snake_name }}.h"
#include "{{ feature_snake_name }}/queries/{{ query.snake_name }}_query.h"
{% for repository in query.repositories %}
#include "repository/interface_{{ repository.snake_name}}_repository.h"{% endfor %}
#include <qleany/common/result.h>
#include <QPromise>

using namespace Qleany;
using namespace {{ application_cpp_domain_name }}::Contracts::DTO::{{ feature_pascal_name }};
{% if query.repositories %}
using namespace {{ application_cpp_domain_name }}::Contracts::Repository;
{% endif %}
using namespace {{ application_cpp_domain_name }}::Contracts::CQRS::{{ feature_pascal_name }}::Queries;

namespace {{ application_cpp_domain_name }}::Application::Features::{{ feature_pascal_name }}::Queries
{
class {{ export }} {{ query.pascal_name }}QueryHandler : public QObject 
{
    Q_OBJECT
  public:
    {{ query.pascal_name }}QueryHandler({% for repository in query.repositories %}
Interface{{ repository.pascal_name }}Repository *{{ repository.camel_name }}Repository {% if not loop.last %},{% endif %}{% endfor %});

    Result<{{ query.dto_out_pascal_name }}> handle(QPromise<Result<void>> &progressPromise, const {{ query.pascal_name }}Query &request);

  signals:
    void {{ query.camel_name }}Changed({{ application_cpp_domain_name }}::Contracts::DTO::{{ feature_pascal_name }}::{{ query.dto_out_pascal_name }} {{ query.dto_out_camel_name }});

  private:
  {% for repository in query.repositories %}
    Interface{{ repository.pascal_name }}Repository *m_{{ repository.camel_name }}Repository;
  {%- endfor %}
    Result<{{ query.dto_out_pascal_name }}> handleImpl(QPromise<Result<void> >   & progressPromise, const {{ query.pascal_name }}Query &request);
    static bool s_mappingRegistered;
    void registerMappings();

};

} // namespace {{ application_cpp_domain_name }}::Application::Features::{{ feature_pascal_name }}::Queries
