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

LuFsFilesCrudController.cs 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System.ComponentModel.DataAnnotations;
  2. using Luticate2.Utils.Dbo.Basic;
  3. using Luticate2.Utils.Dbo.FsFiles;
  4. using Luticate2.Utils.Dbo.PaginatedRequest;
  5. using Luticate2.Utils.Interfaces;
  6. using Luticate2.Utils.Utils;
  7. using Microsoft.AspNetCore.Http;
  8. using Microsoft.AspNetCore.Mvc;
  9. using Microsoft.Extensions.Options;
  10. namespace Luticate2.Utils.Controllers
  11. {
  12. public class LuFsFilesCrudController<TBusiness> : LuController
  13. where TBusiness : ILuCrudInterface<LuFsFilesAddDbo, LuFsFilesDbo, LuFsFilesAddDbo, string>
  14. {
  15. private readonly TBusiness _business;
  16. public LuFsFilesCrudController(IOptions<LuUtilsOptionsDbo> luUtilsOptionsDbo, TBusiness business) : base(luUtilsOptionsDbo)
  17. {
  18. _business = business;
  19. }
  20. [HttpPost]
  21. [Route("[controller]")]
  22. public LuApiWrapperDbo<LuFsFilesDbo> AddDbo([Required]IFormFile file, string path)
  23. {
  24. return Handle(_business.AddDbo(new LuFsFilesAddDbo
  25. {
  26. File = file.OpenReadStream(),
  27. Path = string.IsNullOrEmpty(path) ? file.FileName : path
  28. }));
  29. }
  30. [HttpGet]
  31. [Route("[controller]")]
  32. public virtual LuApiWrapperDbo<LuPaginatedDbo<LuFsFilesDbo>> GetMultiple([Required]LuPaginatedRequestDbo request)
  33. {
  34. return Handle(_business.GetMultiple(request));
  35. }
  36. [HttpPost]
  37. [Route("[controller]/{id}")]
  38. public virtual LuApiWrapperDbo<LuFsFilesDbo> EditSingleByIdDbo([Required]string id, IFormFile file, string path)
  39. {
  40. return Handle(_business.EditSingleByIdDbo(id, new LuFsFilesAddDbo
  41. {
  42. File = file?.OpenReadStream(),
  43. Path = path
  44. }));
  45. }
  46. [HttpDelete]
  47. [Route("[controller]/{id}")]
  48. public virtual LuApiWrapperDbo<LuFsFilesDbo> Delete([Required]string id)
  49. {
  50. return Handle(_business.DeleteSingleByIdDbo(id));
  51. }
  52. }
  53. }