From 45eb6bcac6eaa57efba955dd45aad46f988aaf35 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Sat, 26 Nov 2022 15:55:40 -0600 Subject: Corregido error de mappeo. --- Controllers/RafflesController.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'Controllers') diff --git a/Controllers/RafflesController.cs b/Controllers/RafflesController.cs index 82e05a4..c649b70 100644 --- a/Controllers/RafflesController.cs +++ b/Controllers/RafflesController.cs @@ -82,14 +82,30 @@ namespace BackendPIA.Controllers { [Authorize(Roles = "Administrator")] [HttpPost("{id:int}/play")] - public async Task>> Play(long id) { + public async Task>> Play(long id) { RafflePlayLogic logic = new RafflePlayLogic(_game_service, _service, id); bool result = await logic.Call(); if(!result) return BadRequest(new { ErrorMessage = logic.ErrorMessage }); - return Ok(logic.Winners); + return Ok(_mapper.Map>(logic.Winners)); + } + + [Authorize] + [HttpGet("{id:int}/winners")] + public async Task>> GetWinners(long id) { + var raffle = await _service.GetRaffle(id); + + if(raffle == null) + return NotFound(new NotFoundError(404, $"The raffle with id {id} doesn't exist.")); + + if(!raffle.IsClosed) + return NotFound(new NotFoundError(404, $"The raffle with id {id} doesn't have any winners yet.")); + + var result = await _service.GetRaffleWinners(id); + + return Ok(_mapper.Map>(result)); } } } \ No newline at end of file -- cgit v1.2.3