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 : LuController where TDboCreate : class where TDboRead : class where TDboUpdate : class { protected readonly ILuCrudInterface Busines; protected LuCrudController(ILuCrudInterface busines) { Busines = busines; } [HttpGet] [Route("[controller]/{id}")] public TDboRead GetSingleById(string id) { return Handle(Busines.GetSingleById(id)); } [HttpGet] [Route("[controller]")] public LuPaginatedDbo 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)); } } }