Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

LuCrudInterfaceExtensions.cs 3.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using Luticate2.Utils.Dbo.Basic;
  2. using Luticate2.Utils.Dbo.Filter;
  3. using Luticate2.Utils.Dbo.OrderBy;
  4. using Luticate2.Utils.Dbo.PaginatedRequest;
  5. using Luticate2.Utils.Dbo.Result;
  6. using Luticate2.Utils.Interfaces;
  7. namespace Luticate2.Utils.Utils
  8. {
  9. public static class LuCrudInterfaceExtensions
  10. {
  11. public static LuResult<LuPaginatedDbo<TDboRead>> GetMultiple<TDboCreate, TDboRead, TDboUpdate, TId>(
  12. this ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId> crud, LuOrderByDbo orderBy, LuFilterDbo filter,
  13. int page = 0, int perPage = int.MaxValue)
  14. where TDboCreate : class where TDboRead : class where TDboUpdate : class
  15. {
  16. return crud.GetMultiple(new LuPaginatedRequestDbo
  17. {
  18. Filter = filter,
  19. OrderBy = orderBy,
  20. Page = page,
  21. PerPage = perPage
  22. });
  23. }
  24. public static LuResult<LuPaginatedDbo<TDboRead>> GetMultiple<TDboCreate, TDboRead, TDboUpdate, TId>(
  25. this ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId> crud, LuOrderByDbo orderBy,
  26. int page = 0, int perPage = int.MaxValue)
  27. where TDboCreate : class where TDboRead : class where TDboUpdate : class
  28. {
  29. return crud.GetMultiple(new LuPaginatedRequestDbo
  30. {
  31. Filter = null,
  32. OrderBy = orderBy,
  33. Page = page,
  34. PerPage = perPage
  35. });
  36. }
  37. public static LuResult<TDboRead> AddDbo<TDboCreate, TDboRead, TDboUpdate, TId>(
  38. this ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId> crud, TDboCreate obj)
  39. where TDboCreate : class where TDboRead : class where TDboUpdate : class
  40. {
  41. return crud.Add(obj, o => o);
  42. }
  43. public static LuResult<TId> AddId<TDboCreate, TDboRead, TDboUpdate, TId>(
  44. this ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId> crud, TDboCreate obj)
  45. where TDboCreate : class where TDboRead : class where TDboUpdate : class
  46. {
  47. return crud.Add(obj, crud.GetDboId);
  48. }
  49. public static LuResult<TDboRead> EditSingleByIdDbo<TDboCreate, TDboRead, TDboUpdate, TId>(
  50. this ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId> crud, TId id, TDboUpdate update)
  51. where TDboCreate : class where TDboRead : class where TDboUpdate : class
  52. {
  53. return crud.EditSingleById(id, update, o => o);
  54. }
  55. public static LuResult<TId> EditSingleByIdId<TDboCreate, TDboRead, TDboUpdate, TId>(
  56. this ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId> crud, TId id, TDboUpdate update)
  57. where TDboCreate : class where TDboRead : class where TDboUpdate : class
  58. {
  59. return crud.EditSingleById(id, update, crud.GetDboId);
  60. }
  61. public static LuResult<TDboRead> DeleteSingleByIdDbo<TDboCreate, TDboRead, TDboUpdate, TId>(
  62. this ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId> crud, TId id)
  63. where TDboCreate : class where TDboRead : class where TDboUpdate : class
  64. {
  65. return crud.DeleteSingleById(id, o => o);
  66. }
  67. public static LuResult<TId> DeleteSingleByIdId<TDboCreate, TDboRead, TDboUpdate, TId>(
  68. this ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId> crud, TId id)
  69. where TDboCreate : class where TDboRead : class where TDboUpdate : class
  70. {
  71. return crud.DeleteSingleById(id, crud.GetDboId);
  72. }
  73. }
  74. }