public void AddConcerttoTour(DBContext context, ConcertEngine concertEngine, TourEngine tourEngine) { Console.WriteLine("Введите название тура :"); string tourName = Console.ReadLine(); var tour = tourEngine.GetTourbyName(context, tourName); Console.WriteLine(); Console.WriteLine($"Создание концерта в {tour.Name}"); Console.WriteLine("Введите город :"); string city = Console.ReadLine(); Console.WriteLine("Введите время начала концерта :"); string startDate = Console.ReadLine(); Console.WriteLine("Введите время окончания концерта :"); string endDate = Console.ReadLine(); var concert = new Concert { City = city, StartDate = DateTime.Parse(startDate), EndDate = DateTime.Parse(endDate), Tour = tour }; if (concertEngine.AddConcertToTour(context, concert) != false) { Console.WriteLine("Коцерт добавлен"); } else { Console.WriteLine("Произошла ошибка; Концерт не добавлен"); } }
public void PrintTourInfo(DBContext context, TourEngine tourEngine) { try { Console.WriteLine("Введите название тура :"); string tourName = Console.ReadLine(); var tour = tourEngine.GetTourbyName(context, tourName); int counter = 2; Console.WriteLine($"{tour.Name} {tour.StartDate.ToString("yyyy/MM/dd")} {tour.StartDate.ToString("yyyy/MM/dd")}"); Console.WriteLine(); Console.WriteLine("Концерты тура :"); foreach (var concert in tour.Concerts) { if (counter % 2 == 0) { Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine($"{concert.City} {concert.StartDate} {concert.EndDate}"); Console.ResetColor(); Console.WriteLine(); } else { Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine($"{concert.City} {concert.StartDate} {concert.EndDate}"); Console.ResetColor(); Console.WriteLine(); } counter++; } } catch { Console.WriteLine("Тур с таким названием не существует"); } }