unit Integracao_API.Controller.Comments;

interface

uses Integracao_API.Controller.Interfaces, Integracao_API.Model.Interfaces,
  Integracao_API.DAO.Interfaces, System.Generics.Collections,
  Integracao_API.DAO.Comments, Integracao_API.Model.ConexaoFD;

type
  TControllerComments = class(TInterfacedObject, IControllerComments)
  private
    FDAOComments: IDAOComments;
  public
    constructor Create;
    destructor Destroy; Override;
    class function New: IControllerComments;

    function Salvar(aAcao: TTipoAcao; aObj: IModelComments): Boolean;
    function Excluir(aPOSTID, aID: Integer): Boolean;
    function Buscar(aPOSTID, aID: Integer): IModelComments;
    function BuscarTodos(): TList<IModelComments>;
  end;

implementation

{ TControllerComments }

function TControllerComments.Buscar(aPOSTID, aID: Integer): IModelComments;
begin
  FDAOComments := TDAOComments.Create(TConexaoFireDAC.Instancia.ConexaoBD);
  Result := FDAOComments.Buscar(aPOSTID, aID);
end;

function TControllerComments.BuscarTodos: TList<IModelComments>;
begin

end;

constructor TControllerComments.Create;
begin

end;

destructor TControllerComments.Destroy;
begin

  inherited;
end;

function TControllerComments.Excluir(aPOSTID, aID: Integer): Boolean;
begin
  FDAOComments := TDAOComments.Create(TConexaoFireDAC.Instancia.ConexaoBD);
  Result := FDAOComments.Excluir(aPOSTID, aID);
end;

class function TControllerComments.New: IControllerComments;
begin
  Result := Self.Create;
end;

function TControllerComments.Salvar(aAcao: TTipoAcao;
  aObj: IModelComments): Boolean;
begin
  Result :=  False;
  FDAOComments := TDAOComments.Create(TConexaoFireDAC.Instancia.ConexaoBD);
  case aAcao of
    tpInsert:
    begin
      if FDAOComments. then
      
      Result := FDAOComments.Salvar(tpInsert, aObj);
    end;
    tpUpdate: Result := FDAOComments.Salvar(tpUpdate, aObj);
  end;
end;

end.
