summaryrefslogtreecommitdiff
path: root/Controllers
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2022-11-26 15:55:40 -0600
committerHombreLaser <sebastian-440@live.com>2022-11-26 15:55:40 -0600
commit45eb6bcac6eaa57efba955dd45aad46f988aaf35 (patch)
tree1d87dfdc4e962a35b76e9db9e554c090938e5fc7 /Controllers
parent9fa6c5512cf229bd84ba131577f4a8d2b1efb770 (diff)
Corregido error de mappeo.
Diffstat (limited to 'Controllers')
-rw-r--r--Controllers/RafflesController.cs20
1 files changed, 18 insertions, 2 deletions
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<ActionResult<IEnumerable<RaffleWinner>>> Play(long id) {
+ public async Task<ActionResult<IEnumerable<WinnerDTO>>> 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<IEnumerable<WinnerDTO>>(logic.Winners));
+ }
+
+ [Authorize]
+ [HttpGet("{id:int}/winners")]
+ public async Task<ActionResult<IEnumerable<WinnerDTO>>> 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<IEnumerable<WinnerDTO>>(result));
}
}
} \ No newline at end of file