private string ExecutePrintAllPerformancesCommand() { var performances = database.ListAllPerformances().ToList(); string result = string.Empty; if (performances.Any()) { var allPerformancesAsString = new StringBuilder(); for (int i = 0; i < performances.Count; i++) { if (i > 0) { allPerformancesAsString.Append(", "); } ITheatre teathre = performances[i].Theatre; string performance = performances[i].PerformanceName; string date = performances[i].Date.ToString("dd.MM.yyyy HH:mm"); allPerformancesAsString.AppendFormat("({0}, {1}, {2})", performance, teathre, date); } result = allPerformancesAsString.ToString(); } else { result = "No performances"; } return(result); }
public Performance(ITheatre theatre, string performanceName, DateTime date, TimeSpan duration, decimal price) { this.Theatre = theatre; this.PerformanceName = performanceName; this.Date = date; this.Duration = duration; this.Price = price; }
public void AddPerformance(ITheatre theatre, string performanceName, DateTime date, TimeSpan duration, decimal price) { if (!this.theatresPerformances.ContainsKey(theatre)) { throw new TheatreNotFoundException("Theatre does not exist"); } var performances = this.theatresPerformances[theatre]; var endTime = date + duration; CheckPerformanceDuration(performances, date, endTime); var performance = new Performance(theatre, performanceName, date, duration, price); performances.Add(performance); }
public TheatresController(ITheatre theatre) { Theatre = theatre; }
static void newPerformance(ITheatre availability, int max) { Console.WriteLine("Starting Availability: {0}", availability.checkAvailability()); Seat seat; Seat[] layout; int customerSeat = 1; Console.WriteLine("35 people reserved a seat each"); for (int i = 1; i <= 35; i++) { availability.reserveSeat(i, customerSeat); customerSeat++; } Console.WriteLine("35 people bought a seat each"); for (int i = 1; i < 35; i += 3) { availability.buySeat(i, (customerSeat + i)); } if (availability.returnSeat(5, 5)) { Console.WriteLine("Customer 5 returned their reserved seat: seat 5"); Console.WriteLine("availability: {0}", availability.checkAvailability()); } if (availability.buySeat(1, 1)) { Console.WriteLine("Customer 1 bought seat 1 that they reserved"); Console.WriteLine("availability: {0}", availability.checkAvailability()); } int buySeat = 50; for (int i = 50; i <= 60; i++) { availability.buySeat(i, buySeat); buySeat++; } //availability.cancelReservations(); seat = (availability.checkCustomer(45)); Console.WriteLine("Current Availability {0}", availability.checkAvailability()); Console.WriteLine("Check Customer Seat: {0} | {1}", seat.customer, seat.state); Console.ReadLine(); layout = availability.printSeatingPlan(); int seatNum = 0; for (int i = 0; i < 15; i++) { for (int j = 0; j < 10; j++) { Console.Write("{0}:{1} | ", layout[seatNum].customer, layout[seatNum].state); seatNum++; } Console.WriteLine(); } Console.WriteLine("***** 2 hours until performance, all reserved become available ***** "); availability.removeReserved(); Console.WriteLine(); layout = availability.printSeatingPlan(); seatNum = 0; for (int i = 0; i < 15; i++) { for (int j = 0; j < 10; j++) { Console.Write("{0}:{1} | ", layout[seatNum].customer, layout[seatNum].state); seatNum++; } Console.WriteLine(); } }