Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

LuCrudController.cs 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Linq;
  3. using Luticate2.Utils.Dbo;
  4. using Luticate2.Utils.Dbo.Basic;
  5. using Luticate2.Utils.Dbo.Filter;
  6. using Luticate2.Utils.Dbo.OrderBy;
  7. using Luticate2.Utils.Interfaces;
  8. using Microsoft.AspNetCore.Mvc;
  9. namespace Luticate2.Utils.Controllers
  10. {
  11. public abstract class LuCrudController<TBusiness, TDboCreate, TDboRead, TDboUpdate, TId> : LuController
  12. where TDboCreate : class
  13. where TDboRead : class
  14. where TDboUpdate : class
  15. where TBusiness : ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId>
  16. {
  17. protected readonly TBusiness Busines;
  18. protected LuCrudController(TBusiness busines)
  19. {
  20. Busines = busines;
  21. }
  22. [HttpGet]
  23. [Route("[controller]/{id}")]
  24. public LuApiWrapperDbo<TDboRead> GetSingleById(TId id)
  25. {
  26. return Handle(Busines.GetSingleById(id));
  27. }
  28. [HttpGet]
  29. [Route("[controller]")]
  30. public LuApiWrapperDbo<LuPaginatedDbo<TDboRead>> GetMultiple(LuOrderByDbo orderBy, LuFilterDbo filter,
  31. int page = 0, int perPage = int.MaxValue)
  32. {
  33. return Handle(Busines.GetMultiple(orderBy, filter, page, perPage));
  34. }
  35. [HttpPost]
  36. [Route("[controller]")]
  37. public LuApiWrapperDbo<TDboRead> AddDbo([FromBody]TDboCreate data)
  38. {
  39. return Handle(Busines.AddDbo(data));
  40. }
  41. [HttpPost]
  42. [Route("[controller]/{id}")]
  43. public LuApiWrapperDbo<TDboRead> EditSingleByIdDbo(TId id, [FromBody]TDboUpdate data)
  44. {
  45. return Handle(Busines.EditSingleByIdDbo(id, data));
  46. }
  47. [HttpDelete]
  48. [Route("[controller]/{id}")]
  49. public LuApiWrapperDbo<TDboRead> Delete(TId id)
  50. {
  51. return Handle(Busines.DeleteSingleByIdDbo(id));
  52. }
  53. }
  54. }