123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System.ComponentModel.DataAnnotations;
- using Luticate2.Utils.Dbo.Basic;
- using Luticate2.Utils.Dbo.PaginatedRequest;
- using Luticate2.Utils.Interfaces;
- using Luticate2.Utils.Utils;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Options;
-
- namespace Luticate2.Auth.Controllers
- {
- public abstract class LuAuthCrudController<TBusiness, TDboCreate, TDboRead, TDboUpdate, TId> : LuAuthController
- where TDboCreate : class
- where TDboRead : class
- where TDboUpdate : class
- where TBusiness : ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate, TId>
- {
- protected readonly TBusiness Busines;
-
- protected LuAuthCrudController(TBusiness busines, IOptions<LuUtilsOptionsDbo> luUtilsOptionsDbo) : base(luUtilsOptionsDbo)
- {
- Busines = busines;
- }
-
- [HttpGet("[controller]/{id}")]
- public virtual LuApiWrapperDbo<TDboRead> GetSingleById([Required]TId id)
- {
- return Handle(Busines.GetSingleById(id));
- }
-
- [HttpGet("[controller]")]
- public virtual LuApiWrapperDbo<LuPaginatedDbo<TDboRead>> GetMultiple([Required]LuPaginatedRequestDbo request)
- {
- return Handle(Busines.GetMultiple(request));
- }
-
- [HttpPost("[controller]")]
- public virtual LuApiWrapperDbo<TDboRead> AddDbo([FromBody][Required]TDboCreate data)
- {
- return Handle(Busines.AddDbo(data));
- }
-
- [HttpPost("[controller]/{id}")]
- public virtual LuApiWrapperDbo<TDboRead> EditSingleByIdDbo([Required]TId id, [FromBody][Required]TDboUpdate data)
- {
- return Handle(Busines.EditSingleByIdDbo(id, data));
- }
-
- [HttpDelete("[controller]/{id}")]
- public virtual LuApiWrapperDbo<TDboRead> Delete([Required]TId id)
- {
- return Handle(Busines.DeleteSingleByIdDbo(id));
- }
- }
- }
|