// 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 }}/{{ entity_mappable_with_snake }}_dto.h"
#include "{{ feature_snake_name }}/commands/update_{{ entity_mappable_with_snake }}_command.h"

#include "repository/interface_{{ entity_mappable_with_snake }}_repository.h"
#include <qleany/common/result.h>
#include <QPromise>

using namespace Qleany;
using namespace {{ application_cpp_domain_name }}::Contracts::DTO::{{ feature_pascal_name }};
using namespace {{ application_cpp_domain_name }}::Contracts::Repository;
using namespace {{ application_cpp_domain_name }}::Contracts::CQRS::{{ feature_pascal_name }}::Commands;

namespace {{ application_cpp_domain_name }}::Application::Features::{{ feature_pascal_name }}::Commands
{
class {{ export }} Update{{ entity_mappable_with_pascal }}CommandHandler : public QObject 

{
    Q_OBJECT
  public:
    Update{{ entity_mappable_with_pascal }}CommandHandler(Interface{{ entity_mappable_with_pascal }}Repository *repository);
    Result<{{ entity_mappable_with_pascal }}DTO> handle(QPromise<Result<void>> &progressPromise, const Update{{ entity_mappable_with_pascal }}Command &request);
    Result<{{ entity_mappable_with_pascal }}DTO> restore();

  Q_SIGNALS:
    void {{ entity_mappable_with_camel }}Updated({{ application_cpp_domain_name }}::Contracts::DTO::{{ entity_mappable_with_pascal }}::{{ entity_mappable_with_pascal }}DTO {{ entity_mappable_with_camel }}Dto);
    void {{ entity_mappable_with_camel }}DetailsUpdated(int id);

  private:
    Interface{{ entity_mappable_with_pascal }}Repository *m_repository;
    Result<{{ entity_mappable_with_pascal }}DTO> handleImpl(QPromise<Result<void> >   & progressPromise, const Update{{ entity_mappable_with_pascal }}Command &request);
    Result<{{ entity_mappable_with_pascal }}DTO> restoreImpl();
    Result<{{ entity_mappable_with_pascal }}DTO> saveOldState();
    Result<{{ entity_mappable_with_pascal }}DTO> m_undoState;
    static bool s_mappingRegistered;
    void registerMappings();
};

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