1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- 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>
- {
- private readonly TBusiness _business;
-
- public LuFsFilesCrudController(IOptions<LuUtilsOptionsDbo> luUtilsOptionsDbo, TBusiness business) : base(luUtilsOptionsDbo)
- {
- _business = business;
- }
-
- [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));
- }
- }
- }
|