C#C
C#3y ago
Yashogi

❔ Object reference set to null

var showTime = ShowTimes.Where(x => x.ShowTimeID == request.ShowTimeId).FirstOrDefault();

    int totalTicketsRequested = request.RequireTickets.Count();

    if (showTime.Theatre.SeatingSize < totalTicketsRequested)
    {
        throw new Exception("There are not enough seats available for this purchase");
    }
With the code shown I am trying to grab the showtimeID the user selected and use it to figure out the seating size of the theatre to ensure the total tickets selected by the user don't exceed the seating size
Was this page helpful?