Generic Controller Test
This commit is contained in:
37
LaDOSE.Src/LaDOSE.Api/Controllers/GenericController.cs
Normal file
37
LaDOSE.Src/LaDOSE.Api/Controllers/GenericController.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using LaDOSE.Business.Interface;
|
||||
using LaDOSE.Entity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LaDOSE.Api.Controllers
|
||||
{
|
||||
public class GenericController<T,TU> :Controller where TU : Entity.Context.Entity where T : IBaseService<TU>
|
||||
{
|
||||
protected T _service;
|
||||
|
||||
public GenericController(T service)
|
||||
{
|
||||
_service = service;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public TU Post([FromBody]TU dto)
|
||||
{
|
||||
return _service.Create(dto);
|
||||
}
|
||||
[HttpGet]
|
||||
public List<TU> Get()
|
||||
{
|
||||
|
||||
return _service.GetAll().ToList();
|
||||
|
||||
}
|
||||
[HttpGet("{id}")]
|
||||
public TU Get(int id)
|
||||
{
|
||||
return _service.GetById(id);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user