unit uDelete_PS_HTTPClient;
{< gathers ID from external and Sends it to Server

IDList sent as JSON format

}

interface

uses
  System.SysUtils, System.Classes, System.JSON;

type
  TDelete_PS_HTTPClient = class(TDataModule)
  private
    { Private declarations }

    FIDListToDelete:TStringList;

  public
    { Public declarations }


    constructor Create(AOwner:TComponent); override;

    procedure DeleteByIDList(AIDList:TStringList);
    {< will convert it to JSON and will send to JSON}

    property IDListToDelete:TStringList read FIDListToDelete
    write FIDListToDelete;

  end;

//var
//  Delete: TDelete;

implementation

{%CLASSGROUP 'Vcl.Controls.TControl'}

{$R *.dfm}

{ TDelete }


uses uVisualFrame;

var VisualFrame_HTTP_UnitVar:TVisualFrame_HTTP;


constructor TDelete_PS_HTTPClient.Create(AOwner: TComponent);
begin
  inherited;


  if (Aowner is TVisualFrame_HTTP) then
  VisualFrame_HTTP_UnitVar:=(Aowner as TVisualFrame_HTTP);



end;

procedure TDelete_PS_HTTPClient.DeleteByIDList(AIDList: TStringList);

var JSONObject:TJSONObject;
    i: Integer;
    JsonStringWithIDValues: String;

begin


JSONObject:=TJSONObject.Create;
try

// --- converting to JSON

for i := 0 to AIDList.Count-1 do
JSONObject.AddPair( (TJSONPair.Create(i.ToString,AIDList[i] )) );
JsonStringWithIDValues:=JSONObject.ToString();


//Sending it to Server
VisualFrame_HTTP_UnitVar.
HTTPRequests.
DeleteFoldersAndFilesOnServerWithDataBase(JsonStringWithIDValues);



finally


FreeAndNil(JSONObject);

end;




end;

end.
