2
0

crudclient.dpr 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. (* _ _
  2. * | |__ _ __ ___ ___ | | __
  3. * | '_ \| '__/ _ \ / _ \| |/ /
  4. * | |_) | | | (_) | (_) | <
  5. * |_.__/|_| \___/ \___/|_|\_\
  6. *
  7. * Microframework which helps to develop web Pascal applications.
  8. *
  9. * Copyright (c) 2012-2021 Silvio Clecio <[email protected]>
  10. *
  11. * Brook framework is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation; either
  14. * version 2.1 of the License, or (at your option) any later version.
  15. *
  16. * Brook framework is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public
  22. * License along with Brook framework; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. *)
  25. program crudclient;
  26. {$IFDEF MSWINDOWS}
  27. {$APPTYPE CONSOLE}
  28. {$ENDIF}
  29. uses
  30. Data.DB,
  31. Client;
  32. const
  33. URL_SERVER = 'http://localhost:8080';
  34. procedure ListAllPersons;
  35. begin
  36. with ListPersons(URL_SERVER) do
  37. try
  38. while not EOF do
  39. begin
  40. WriteLn(FieldByName('id').AsInteger, ' ', FieldByName('name').AsString);
  41. Next;
  42. end;
  43. finally
  44. Free;
  45. end;
  46. end;
  47. procedure AddRandomPersons;
  48. var
  49. VDataSet: TDataSet;
  50. VField: TField;
  51. begin
  52. VDataSet := CreatePersonsDataSet;
  53. VField := VDataSet.FieldByName('name');
  54. VDataSet.Append;
  55. VField.AsString := 'Person ' + NewGuid;
  56. VDataSet.Append;
  57. VField.AsString := 'Person ' + NewGuid;
  58. SavePersons(URL_SERVER, VDataSet);
  59. end;
  60. begin
  61. ListAllPersons;
  62. AddRandomPersons;
  63. ListAllPersons;
  64. end.