12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using Luticate2.Utils.Dbo.Basic;
- using Luticate2.Utils.Dbo.Filter;
- using Luticate2.Utils.Dbo.OrderBy;
- using Luticate2.Utils.Dbo.PaginatedRequest;
- using Luticate2.Utils.Dbo.Result;
- using Luticate2.Utils.Interfaces;
-
- namespace Luticate2.Utils.Utils
- {
- public static class LuCrudInterfaceExtensions
- {
- public static LuResult<LuPaginatedDbo<TDboRead>> GetMultiple<TDboCreate, TDboRead, TDboUpdate, TId>(
- this ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId> crud, LuOrderByDbo orderBy, LuFilterDbo filter,
- int page = 0, int perPage = int.MaxValue)
- where TDboCreate : class where TDboRead : class where TDboUpdate : class
- {
- return crud.GetMultiple(new LuPaginatedRequestDbo
- {
- Filter = filter,
- OrderBy = orderBy,
- Page = page,
- PerPage = perPage
- });
- }
-
- public static LuResult<LuPaginatedDbo<TDboRead>> GetMultiple<TDboCreate, TDboRead, TDboUpdate, TId>(
- this ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId> crud, LuOrderByDbo orderBy,
- int page = 0, int perPage = int.MaxValue)
- where TDboCreate : class where TDboRead : class where TDboUpdate : class
- {
- return crud.GetMultiple(new LuPaginatedRequestDbo
- {
- Filter = null,
- OrderBy = orderBy,
- Page = page,
- PerPage = perPage
- });
- }
-
- public static LuResult<TDboRead> AddDbo<TDboCreate, TDboRead, TDboUpdate, TId>(
- this ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId> crud, TDboCreate obj)
- where TDboCreate : class where TDboRead : class where TDboUpdate : class
- {
- return crud.Add(obj, o => o);
- }
-
- public static LuResult<TId> AddId<TDboCreate, TDboRead, TDboUpdate, TId>(
- this ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId> crud, TDboCreate obj)
- where TDboCreate : class where TDboRead : class where TDboUpdate : class
- {
- return crud.Add(obj, crud.GetDboId);
- }
-
- public static LuResult<TDboRead> EditSingleByIdDbo<TDboCreate, TDboRead, TDboUpdate, TId>(
- this ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId> crud, TId id, TDboUpdate update)
- where TDboCreate : class where TDboRead : class where TDboUpdate : class
- {
- return crud.EditSingleById(id, update, o => o);
- }
-
- public static LuResult<TId> EditSingleByIdId<TDboCreate, TDboRead, TDboUpdate, TId>(
- this ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId> crud, TId id, TDboUpdate update)
- where TDboCreate : class where TDboRead : class where TDboUpdate : class
- {
- return crud.EditSingleById(id, update, crud.GetDboId);
- }
-
- public static LuResult<TDboRead> DeleteSingleByIdDbo<TDboCreate, TDboRead, TDboUpdate, TId>(
- this ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId> crud, TId id)
- where TDboCreate : class where TDboRead : class where TDboUpdate : class
- {
- return crud.DeleteSingleById(id, o => o);
- }
-
- public static LuResult<TId> DeleteSingleByIdId<TDboCreate, TDboRead, TDboUpdate, TId>(
- this ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId> crud, TId id)
- where TDboCreate : class where TDboRead : class where TDboUpdate : class
- {
- return crud.DeleteSingleById(id, crud.GetDboId);
- }
- }
- }
|