clean code + add interface

pull/4/head
Alexandre Ruiz 3 years ago
parent 24983a0fa0
commit 84e6c3b08c
  1. 7
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/AgenceController.cs
  2. 2
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/BaseController.cs
  3. 8
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/BusinessUnitController.cs
  4. 9
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/CollaborateursController.cs
  5. 7
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/FonctionController.cs
  6. 16
      Collaborateur_Epa_Back/espacecollab.backend.api/Controllers/IBaseController.cs

@ -1,12 +1,11 @@
using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
namespace espacecollab.backend.api.Controllers
namespace espacecollab.backend.api.Controllers;
public class AgenceController : BaseController<AgenceApiDto>
{
public class AgenceController : BaseController<AgenceApiDto>
{
public AgenceController(AgenceService agenceService) : base(agenceService)
{
}
}
}

@ -6,7 +6,7 @@ namespace espacecollab.backend.api.Controllers
{
[Route("api/[controller]")]
[ApiController]
public abstract class BaseController<TO> : Controller where TO : class, IGenericIdApiDto
public abstract class BaseController<TO> : Controller, IBaseController<TO> where TO : class, IGenericIdApiDto
{
protected IGenericsServices<TO> Services { get; }

@ -1,13 +1,11 @@
using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
using espacecollab.backend.infrastructure.sql.dtos;
namespace espacecollab.backend.api.Controllers
namespace espacecollab.backend.api.Controllers;
public class BusinessUnitController : BaseController<BusinessUnitApiDto>
{
public class BusinessUnitController : BaseController<BusinessUnitApiDto>
{
public BusinessUnitController(BusinessUnitService businessUnitService) : base(businessUnitService)
{
}
}
}

@ -2,12 +2,10 @@
using espacecollab.backend.appservices.dtos;
using Microsoft.AspNetCore.Mvc;
namespace espacecollab.backend.api.Controllers
namespace espacecollab.backend.api.Controllers;
public class CollaborateursController : BaseController<CollaborateurApiDto>
{
//[Route("api/[controller]")]
//[ApiController]
public class CollaborateursController : BaseController<CollaborateurApiDto>
{
private CollaborateursService CollaborateursServices { get; }
public CollaborateursController(CollaborateursService collaborateursServices) : base(collaborateursServices)
@ -44,5 +42,4 @@ namespace espacecollab.backend.api.Controllers
return Ok(collaborateur);
}
}
}

@ -1,12 +1,11 @@
using espacecollab.backend.appservices;
using espacecollab.backend.appservices.dtos;
namespace espacecollab.backend.api.Controllers
namespace espacecollab.backend.api.Controllers;
public class FonctionController : BaseController<FonctionApiDto>
{
public class FonctionController : BaseController<FonctionApiDto>
{
public FonctionController(FonctionService fonctionService) : base(fonctionService)
{
}
}
}

@ -0,0 +1,16 @@
using Microsoft.AspNetCore.Mvc;
namespace espacecollab.backend.api.Controllers;
public interface IBaseController<TO>
{
ActionResult<IEnumerable<TO>> GetAll();
ActionResult<TO> GetById(uint id);
ActionResult<TO> Add(TO apiDto);
ActionResult Delete(uint id);
ActionResult<TO> Update(uint id, TO apiDto);
}
Loading…
Cancel
Save