| | 1 | | using Despesas.Application.Abstractions; |
| | 2 | | using Despesas.Application.Dtos; |
| | 3 | | using Microsoft.AspNetCore.Authorization; |
| | 4 | | using Microsoft.AspNetCore.Mvc; |
| | 5 | |
|
| | 6 | | namespace Despesas.Backend.Controllers; |
| | 7 | |
|
| | 8 | | public class LancamentoController : AuthController |
| | 9 | | { |
| | 10 | | private ILancamentoBusiness<LancamentoDto> _lancamentoBusiness; |
| 4 | 11 | | public LancamentoController(ILancamentoBusiness<LancamentoDto> lancamentoBusiness) |
| 4 | 12 | | { |
| 4 | 13 | | _lancamentoBusiness = lancamentoBusiness; |
| 4 | 14 | | } |
| | 15 | |
|
| | 16 | | [HttpGet("{anoMes}")] |
| | 17 | | [Authorize("Bearer", Roles = "User, Admin")] |
| | 18 | | [ProducesResponseType(200, Type = typeof(List<LancamentoDto>))] |
| | 19 | | [ProducesResponseType(401)] |
| | 20 | | [ProducesResponseType(403)] |
| | 21 | | public async Task<IActionResult> Get([FromRoute] DateTime anoMes) |
| 4 | 22 | | { |
| | 23 | | try |
| 4 | 24 | | { |
| 4 | 25 | | var list = await _lancamentoBusiness.FindByMesAno(anoMes, UserIdentity); |
| 2 | 26 | | if (list == null || list.Count == 0) |
| 1 | 27 | | return Ok(new List<LancamentoDto>()); |
| | 28 | |
|
| 1 | 29 | | return Ok(list); |
| | 30 | | } |
| 2 | 31 | | catch |
| 2 | 32 | | { |
| 2 | 33 | | return Ok(new List<LancamentoDto>()); |
| | 34 | | } |
| 4 | 35 | | } |
| | 36 | | } |