diff options
author | HombreLaser <sebastian-440@live.com> | 2022-11-27 14:10:25 -0600 |
---|---|---|
committer | HombreLaser <sebastian-440@live.com> | 2022-11-27 14:10:25 -0600 |
commit | 9149e64398e7b9f7b29bcf68db7eff2ce5f8169c (patch) | |
tree | 74cc38b343100c6c9b0bb2d23886b5bc1677c039 /Logics/CreateTicketLogic.cs | |
parent | 6f263df59a895b6bcc2fe22b9626ddd81537c217 (diff) |
Corregidos algunos bugs
Diffstat (limited to 'Logics/CreateTicketLogic.cs')
-rw-r--r-- | Logics/CreateTicketLogic.cs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Logics/CreateTicketLogic.cs b/Logics/CreateTicketLogic.cs index df64a1a..be3c66c 100644 --- a/Logics/CreateTicketLogic.cs +++ b/Logics/CreateTicketLogic.cs @@ -24,17 +24,26 @@ namespace BackendPIA.Logics { } public async Task<bool> Call() { + var raffle = _context.Raffles.Find(_raffle_id); + // Check if the user exists. if(_user == null) return false; // Check if the given raffle exists- - if(!_context.Raffles.Any(r => r.Id == _raffle_id)) { + if(raffle == null) { ErrorMessage = "The raffle doesn't exist."; return false; } + // Check if the raffle has already closed. + if(raffle.IsClosed) { + ErrorMessage = "The raffle is already closed."; + + return false; + } + // Check if the user already has a ticket for the given raffle. if(_context.Tickets.Where(t => t.RaffleId == _raffle_id).Where(t => t.UserAccountId == _user.Id).Count() > 0) { ErrorMessage = $"There's already a ticket for {_user.UserName}."; |