init
This commit is contained in:
12
OpenCand.API/Controllers/BaseController.cs
Normal file
12
OpenCand.API/Controllers/BaseController.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace OpenCand.API.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("v1/[controller]")]
|
||||
[Produces("application/json")]
|
||||
public class BaseController : Controller
|
||||
{
|
||||
|
||||
}
|
||||
}
|
41
OpenCand.API/Controllers/CandidatoController.cs
Normal file
41
OpenCand.API/Controllers/CandidatoController.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenCand.API.Model;
|
||||
using OpenCand.API.Services;
|
||||
using OpenCand.Core.Models;
|
||||
|
||||
namespace OpenCand.API.Controllers
|
||||
{
|
||||
public class CandidatoController : BaseController
|
||||
{
|
||||
private readonly OpenCandService openCandService;
|
||||
|
||||
public CandidatoController(OpenCandService openCandService)
|
||||
{
|
||||
this.openCandService = openCandService;
|
||||
}
|
||||
|
||||
[HttpGet("search")]
|
||||
public async Task<CandidatoSearchResult> CandidatoSearch([FromQuery] string q)
|
||||
{
|
||||
return await openCandService.SearchCandidatosAsync(q);
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public async Task<Candidato> GetCandidatoById([FromRoute] Guid id)
|
||||
{
|
||||
return await openCandService.GetCandidatoAsync(id);
|
||||
}
|
||||
|
||||
[HttpGet("{id}/bens")]
|
||||
public async Task<BemCandidatoResult> GetBensCandidatoById([FromRoute] Guid id)
|
||||
{
|
||||
return await openCandService.GetBemCandidatoById(id);
|
||||
}
|
||||
|
||||
[HttpGet("{id}/rede-social")]
|
||||
public async Task<RedeSocialResult> GetCandidatoRedeSocialById([FromRoute] Guid id)
|
||||
{
|
||||
return await openCandService.GetCandidatoRedeSocialById(id);
|
||||
}
|
||||
}
|
||||
}
|
22
OpenCand.API/Controllers/StatsController.cs
Normal file
22
OpenCand.API/Controllers/StatsController.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenCand.API.Services;
|
||||
using OpenCand.Core.Models;
|
||||
|
||||
namespace OpenCand.API.Controllers
|
||||
{
|
||||
public class StatsController : BaseController
|
||||
{
|
||||
private readonly OpenCandService openCandService;
|
||||
|
||||
public StatsController(OpenCandService openCandService)
|
||||
{
|
||||
this.openCandService = openCandService;
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
public async Task<OpenCandStats> GetStats()
|
||||
{
|
||||
return await openCandService.GetOpenCandStatsAsync();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user