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