123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System.ComponentModel.DataAnnotations;
- using Luticate2.Utils.Dbo.Basic;
- using Luticate2.Utils.Dbo.FsFiles;
- using Luticate2.Utils.Dbo.PaginatedRequest;
- using Luticate2.Utils.Interfaces;
- using Luticate2.Utils.Utils;
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Options;
-
- namespace Luticate2.Utils.Controllers
- {
- public class LuFsFilesCrudController<TBusiness> : LuController
- where TBusiness : ILuCrudInterface<LuFsFilesAddDbo, LuFsFilesDbo, LuFsFilesAddDbo, string>
- {
- protected readonly TBusiness Business;
-
- public LuFsFilesCrudController(IOptions<LuUtilsOptionsDbo> luUtilsOptionsDbo, TBusiness business) : base(luUtilsOptionsDbo)
- {
- Business = business;
- }
-
- [HttpGet]
- [Route("[controller]/{id}")]
- public virtual LuApiWrapperDbo<LuFsFilesDbo> GetSingleById([Required]string id)
- {
- return Handle(Business.GetSingleById(id));
- }
-
- [HttpPost]
- [Route("[controller]")]
- public LuApiWrapperDbo<LuFsFilesDbo> AddDbo([Required]IFormFile file, string path)
- {
- return Handle(Business.AddDbo(new LuFsFilesAddDbo
- {
- File = file.OpenReadStream(),
- Path = string.IsNullOrEmpty(path) ? file.FileName : path
- }));
- }
-
- [HttpGet]
- [Route("[controller]")]
- public virtual LuApiWrapperDbo<LuPaginatedDbo<LuFsFilesDbo>> GetMultiple([Required]LuPaginatedRequestDbo request)
- {
- return Handle(Business.GetMultiple(request));
- }
-
- [HttpPost]
- [Route("[controller]/{id}")]
- public virtual LuApiWrapperDbo<LuFsFilesDbo> EditSingleByIdDbo([Required]string id, IFormFile file, string path)
- {
- return Handle(Business.EditSingleByIdDbo(id, new LuFsFilesAddDbo
- {
- File = file?.OpenReadStream(),
- Path = path
- }));
- }
-
- [HttpDelete]
- [Route("[controller]/{id}")]
- public virtual LuApiWrapperDbo<LuFsFilesDbo> Delete([Required]string id)
- {
- return Handle(Business.DeleteSingleByIdDbo(id));
- }
- }
- }
|