public static Ticket FillTicket_1(Ticket ticket1, FilmScreening[] filmScreenings, Seat[] seats, Viewer viewer1) { ticket1.Number = 224456789; ticket1.FilmScreening = filmScreenings[0]; ticket1.Seat = seats[2]; ticket1.Price = 90; ticket1.Viewer = viewer1; return(ticket1); }
public Ticket BuyTicket(int filmId, int filmScreeningId, int seatNumber, decimal price, Viewer viewer) { FilmScreening filmScreening = GetFilmScreening(filmId, filmScreeningId); try { if (filmScreening != null && GetFilmScreeningPrice(filmId, filmScreeningId, seatNumber) == price) { if (filmScreening.Film.MinAge <= viewer.Age) { if (filmScreening.SeatPlaces[seatNumber].Busy != true) { Money += price; Ticket ticket = new Ticket(Tickets.Length, filmScreening, filmScreening.SeatPlaces[seatNumber], viewer, price); //Повернення грошей, за 3 години до сеансу. //if (filmScreening.DateTime < DateTime.Now&& DateTime.Now < filmScreening.DateTime.AddHours(-3)) if (filmScreening.DateTime > new DateTime(2021, 2, 25, 17, 30, 00) && new DateTime(2021, 2, 25, 17, 30, 00) > filmScreening.DateTime.AddHours(-3)) { Money -= price; Console.WriteLine($"The money {price} has been turned"); } else { filmScreening.SeatPlaces[seatNumber].Busy = true; Console.WriteLine("Ticket purchased successfully"); return(ticket); } } else { throw new BusySeatException("Place is taken!"); } } else { throw new InvalidAgeException("Your age is restricted"); } } else { throw new NotExistException("No such film found!"); } } catch (ApplicationException e) { Console.WriteLine($"Error: {e.Message}"); } return(null); }