private static void ProcessTicket(Theatre theatre, Performance performance, Ticket ticket, Client client) { Console.WriteLine(); Console.WriteLine($"You've chosen ticket with price {ticket.Price} ₴"); Console.WriteLine("Which action you want to do?"); Console.WriteLine("1: Buy this ticket"); Console.WriteLine("2: Book this ticket"); Console.WriteLine(); string action = Console.ReadLine(); if (action == "1") { if (client.CanAfford(ticket)) { theatre.SellTicket(performance, ticket); client.ChargeClient(ticket.Price); client.AddTicket(ticket.ChangeState(TicketState.BOUGHT)); Console.WriteLine($"Ticket with price {ticket.Price} ₴ on performance {ticket.Performance.Name}" + " was added to your bought tickets"); } else { Console.WriteLine(Constants.NotEnoughMoney); } } else if (action == "2") { theatre.SellTicket(performance, ticket); client.AddTicket(ticket.ChangeState(TicketState.BOOKED)); Task.Run(async delegate { await Task.Delay(Constants.BookTime); if (client.CanAfford(ticket)) { client.ChargeClient(ticket.Price); client[client.FindTicket(ticket)].ChangeState(TicketState.BOUGHT); Console.WriteLine( $"Ticket with price {ticket.Price} ₴ on performance {ticket.Performance.Name}"); Console.WriteLine("Was moved from booked tickets to your bought tickets."); } else { Console.WriteLine( $"Ticket with price {ticket.Price} ₴ on performance {ticket.Performance.Name}"); Console.WriteLine("Wasn't moved from booked tickets to your bought tickets."); performance.AddTicket(ticket.ChangeState(TicketState.SELLING)); Console.WriteLine(Constants.NotEnoughMoney); } }); } else { Console.WriteLine(Constants.WrongChoice); } }