Files
LaDOSE/LaDOSE.Src/LaDOSE.Api/Controllers/GenericController.cs

39 lines
798 B
C#
Raw Normal View History

2018-10-12 20:52:59 +02:00
using System.Collections.Generic;
using System.Linq;
using LaDOSE.Business.Interface;
using LaDOSE.Entity;
using Microsoft.AspNetCore.Mvc;
namespace LaDOSE.Api.Controllers
{
2019-03-12 22:23:38 +01:00
public class GenericController<T, TU> : Controller where TU : Entity.Context.Entity where T : IBaseService<TU>
2018-10-12 20:52:59 +02:00
{
protected T _service;
public GenericController(T service)
{
_service = service;
}
[HttpPost]
2019-03-12 22:23:38 +01:00
public TU Post([FromBody] TU dto)
2018-10-12 20:52:59 +02:00
{
2019-03-09 14:03:25 +01:00
return _service.AddOrUpdate(dto);
2018-10-12 20:52:59 +02:00
}
2019-03-12 22:23:38 +01:00
2018-10-12 20:52:59 +02:00
[HttpGet]
public List<TU> Get()
{
return _service.GetAll().ToList();
}
2019-03-12 22:23:38 +01:00
2018-10-12 20:52:59 +02:00
[HttpGet("{id}")]
public TU Get(int id)
{
return _service.GetById(id);
}
}
}