adding despesas e receitas
This commit is contained in:
42
OpenCand.API/Repository/DespesaReceitaRepository.cs
Normal file
42
OpenCand.API/Repository/DespesaReceitaRepository.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Npgsql;
|
||||
using OpenCand.Core.Models;
|
||||
|
||||
namespace OpenCand.Repository
|
||||
{
|
||||
public class DespesaReceitaRepository : BaseRepository
|
||||
{
|
||||
public DespesaReceitaRepository(IConfiguration configuration) : base(configuration)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<List<Despesa>> GetDespesasByCandidatoIdYearAsync(Guid idcandidato)
|
||||
{
|
||||
using (var connection = new NpgsqlConnection(ConnectionString))
|
||||
{
|
||||
return (await connection.QueryAsync<Despesa>(@"
|
||||
SELECT * FROM despesas_candidato
|
||||
WHERE idcandidato = @idcandidato
|
||||
ORDER BY valor DESC;", new
|
||||
{
|
||||
idcandidato
|
||||
})).AsList();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<Receita>> GetReceitasByCandidatoIdYearAsync(Guid idcandidato)
|
||||
{
|
||||
using (var connection = new NpgsqlConnection(ConnectionString))
|
||||
{
|
||||
return (await connection.QueryAsync<Receita>(@"
|
||||
SELECT * FROM receitas_candidato
|
||||
WHERE idcandidato = @idcandidato
|
||||
ORDER BY valor DESC;", new
|
||||
{
|
||||
idcandidato
|
||||
})).AsList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user