public List <string> GetBookedTickets(int showID) { try { return(bookingRep.GetBookedSeats(showID)); } catch (Exception ex) { return(null); } }
public ActionResult DisplaySeats(int showID, DateTime showTime) { try { Session["ShowTime"] = showTime; var theatre = Mapper.Map <bookMySeat.Theatre, Models.Theatre>(rep.GetTheatre(showID)); var bookedSeats = rep.GetBookedSeats(showID); ViewBag.ShowID = showID; ViewBag.Theatre = theatre; List <Models.SeatViewModel> seats = new List <Models.SeatViewModel>(); char seatLetter = 'A'; for (int i = 0; i < theatre.PremiumRows; i++) { for (int j = 0; j < theatre.PremiumSeats / theatre.PremiumRows; j++) { Models.SeatViewModel seat = new Models.SeatViewModel(); seat.SeatNumber = seatLetter + j.ToString(); seat.SeatType = "Premium"; seats.Add(seat); } seatLetter++; } for (int i = 0; i < theatre.StandardRows; i++) { for (int j = 0; j < theatre.StandardSeats / theatre.StandardRows; j++) { Models.SeatViewModel seat = new Models.SeatViewModel(); seat.SeatNumber = seatLetter + j.ToString(); seat.SeatType = "Standard"; seats.Add(seat); } seatLetter++; } foreach (var seat in seats) { if (bookedSeats.Contains(seat.SeatNumber)) { seat.IsBooked = true; } } return(View(seats)); } catch (Exception ex) { return(View("Error")); } }