fix: add place already taken validation
This commit is contained in:
parent
8141ac5307
commit
6413d88ffc
@ -23,7 +23,7 @@ public class IndexModel : PageModel
|
||||
|
||||
private readonly TicketOfficeContext _context;
|
||||
|
||||
public IndexModel(TicketOfficeContext context, ILogger<IndexModel> logger)
|
||||
public IndexModel(TicketOfficeContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
@ -195,6 +195,14 @@ public class IndexModel : PageModel
|
||||
validationError = "Поле має бути заповненим";
|
||||
return false;
|
||||
}
|
||||
|
||||
Ticket? ticket = _context.Ticket.FirstOrDefault(t => t.RouteId == Ticket.RouteId && t.PassengerPlace == Ticket.PassengerPlace);
|
||||
|
||||
if (ticket is not null)
|
||||
{
|
||||
validationError = "Місце вже зайняте";
|
||||
return false;
|
||||
}
|
||||
|
||||
validationError = String.Empty;
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user