12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using Luticate2.Utils.Dbo;
- using Luticate2.Utils.Dbo.OrderBy;
- using Luticate2.Utils.Interfaces;
- using Microsoft.AspNetCore.Mvc;
-
- namespace Luticate2.Utils.Controllers
- {
- public abstract class LuCrudController<TDboCreate, TDboRead, TDboUpdate> : LuController
- where TDboCreate : class
- where TDboRead : class
- where TDboUpdate : class
- {
- protected readonly ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate> Busines;
-
- protected LuCrudController(ILuCrudInterface<TDboCreate, TDboRead, TDboUpdate> busines)
- {
- Busines = busines;
- }
-
- [HttpGet]
- [Route("[controller]/{id}")]
- public TDboRead GetSingleById(string id)
- {
- return Handle(Busines.GetSingleById(id));
- }
-
- [HttpGet]
- [Route("[controller]")]
- public LuPaginatedDbo<TDboRead> GetMultiple(LuOrderByDbo orderBy, int page = 0, int perPage = int.MaxValue)
- {
- return Handle(Busines.GetMultiple(orderBy, page, perPage));
- }
-
- [HttpPost]
- [Route("[controller]")]
- public TDboRead Add([FromBody]TDboCreate data)
- {
- return Handle(Busines.AddDbo(data));
- }
-
- [HttpPost]
- [Route("[controller]/{id}")]
- public TDboRead Edit(string id, [FromBody]TDboUpdate data)
- {
- return Handle(Busines.EditSingleByIdDbo(id, data));
- }
-
- [HttpDelete]
- [Route("[controller]/{id}")]
- public TDboRead Delete(string id)
- {
- return Handle(Busines.DeleteSingleByIdDbo(id));
- }
- }
- }
|