Beispiel #1
0
 /// <summary>
 /// According to the table the user chose to work with in the begining the information is passed to one of the other displays.
 /// </summary>
 /// <remarks>The method gets all data in the table.</remarks>
 private static void AddNewEntry()
 {
     Console.Clear();
     if (numberTable == 3)
     {
         townsDisplay.AddTown();
     }
     else if (numberTable == 4)
     {
         competitorsDisplay.AddCompetitor();
     }
     else if (numberTable == 5)
     {
         coachesDisplay.AddCoach();
     }
     else if (numberTable == 6)
     {
         clubsDisplay.AddClub();
     }
     Console.WriteLine();
     Console.WriteLine("Press any key to clear the screen..."); Console.ReadKey(); Console.Clear();
 }
Beispiel #2
0
        private Competitors CreateCompetitor(Competitors competitor)
        {
            Console.Write("Enter Competitor Full Name: ");
            competitor.FullName = Console.ReadLine();
            Console.Write("Enter Competitor Birth Date: ");
            competitor.BirthDate = Console.ReadLine();
            Console.Write("Enter Competitor Age: ");
            competitor.Age = int.Parse(Console.ReadLine());
            Console.Write("Enter Competitor Gender: ");
            competitor.Gender = Console.ReadLine();
            Console.Write("Enter Competitor Weight: ");
            competitor.Weight = Console.ReadLine();

            Console.Write("Enter Competitor Town Name: ");
            string townName = Console.ReadLine();

            if (townsBusiness.GetTownByName(townName) == null)
            {
                Console.WriteLine($"There is no town with the name {townName}");
                Console.WriteLine("Do you want to create new town?");
                Console.WriteLine("1. Yes" + "\n" + "2. No");
                if (int.Parse(Console.ReadLine()) == 1)
                {
                    townsDisplay.AddTown();
                }
                else
                {
                    Console.Write("Enter existing town: ");
                    townName = Console.ReadLine();
                }
            }
            competitor.TownId = townsBusiness.GetTownByName(townName).Id;

            Console.WriteLine("Do your competitor have a club?" + "\n" + "1.Yes" + "\n" + "2.No");
            if (int.Parse(Console.ReadLine()) == 1)
            {
                Console.Write("Enter Competitor Club Name: ");
                string clubName = Console.ReadLine();
                if (clubsBusiness.GetClubByName(clubName) == null)
                {
                    Console.WriteLine($"There is no club with the name {clubName}");
                    Console.WriteLine("Do you want to create new club?");
                    Console.WriteLine("1. Yes" + "\n" + "2. No");
                    if (int.Parse(Console.ReadLine()) == 1)
                    {
                        clubsDisplay.AddClub();
                    }
                    else
                    {
                        Console.WriteLine("Enter existing club: ");
                        clubName = Console.ReadLine();
                    }
                }
                competitor.ClubId = clubsBusiness.GetClubByName(clubName).Id;
            }
            else
            {
                competitor.ClubId = null;
            }

            Console.WriteLine("Do your competitor have a coach?" + "\n" + "1.Yes" + "\n" + "2.No");
            if (int.Parse(Console.ReadLine()) == 1)
            {
                Console.Write("Enter Competitor Coach Name: ");
                string coachName = Console.ReadLine();
                if (coachesBusiness.GetCoachByName(coachName) == null)
                {
                    Console.WriteLine($"There is no coach with the name {coachName}");
                    Console.WriteLine("Do you want to create new coach?");
                    Console.WriteLine("1. Yes" + "\n" + "2. No");
                    if (int.Parse(Console.ReadLine()) == 1)
                    {
                        coachesDisplay.AddCoach();
                    }
                    else
                    {
                        Console.WriteLine("Enter existing coach: ");
                        coachName = Console.ReadLine();
                    }
                }
                competitor.CoachId = coachesBusiness.GetCoachByName(coachName).Id;
            }
            else
            {
                competitor.CoachId = null;
            }

            Console.Write("Enter Competitor Sport Name: ");
            string sportName = Console.ReadLine();

            competitor.SportId = sportsBusiness.GetSportByName(sportName).Id;

            return(competitor);
        }