Esempio n. 1
0
 public void AddTeam(Team teamToBeAdded)
 {
     using (MNSportsTeamContext context = new MNSportsTeamContext())
     {
         context.Teams.Add(teamToBeAdded);
         context.SaveChanges();
     }
 }
Esempio n. 2
0
        public Team CreateTeam()
        {
            Team newTeam = new Team();
            int Id;
            bool isValid = false;
            Console.Clear();
            bool isActive = false;
            Console.Write("Enter the name of the team: ");
            string name = Console.ReadLine();
            Console.Write("\nSport: ");
            string sport = Console.ReadLine();
            Console.Write("\nMascot: ");
            string mascot = Console.ReadLine();
            Console.Write("\nCoach: ");
            string coach = Console.ReadLine();
            Console.Write("\nOwner: ");
            string owner = Console.ReadLine();
            Console.Write("\nAverage Salary: ");
            decimal salary = decimal.Parse(Console.ReadLine());
            Console.Write("\nIs the team still active(Y/N): ");
            string active = Console.ReadLine();
            if (active.ToUpper() == "Y")
            {
                isActive = true;
            }
            else
            {
                isActive = false;
            }
            Console.Write("\nNumber of Convictions: ");
            int convictions = int.Parse(Console.ReadLine());

            VenueOps ops = new VenueOps();
            do {
                Console.Clear();
                ops.DisplayVenues();
                Console.Write("Enter the number that corresponds with the Venue Building.\nIf you do not know the building name press enter.\nIf you do know the name of the building, type 'Building'");
                string venue = Console.ReadLine();
                if (int.TryParse(venue, out Id))
                {
                    newTeam.VenueId = Id;
                    isValid = true;
                }
                else if (venue == "")
                {
                    newTeam.VenueId = null;
                    isValid = true;
                }
                else if (venue.ToUpper() == "BUILDING")
                {
                    Venue created = ops.CreateVenue();
                    ops.AddVenue(created);
                    isValid = false;
                }
                else
                {
                    isValid = false;
                }
            } while (!isValid);

            newTeam.Name = name;
            newTeam.Sport = sport;
            newTeam.Mascot = mascot;
            newTeam.Coach = coach;
            newTeam.Owner = owner;
            newTeam.AvgSalary = salary;
            newTeam.Active = isActive;
            newTeam.Convictions = convictions;

            return newTeam;
        }
Esempio n. 3
0
 public List<Team> GetAllTeams()
 {
     List<Team> teamList = new List<Team>();
     using (MNSportsTeamContext context = new MNSportsTeamContext())
     {
         foreach (var team in context.Teams)
         {
             Team newTeam = new Team();
             newTeam.TeamId = team.TeamId;
             newTeam.Name = team.Name;
             newTeam.Sport = team.Sport;
             newTeam.Mascot = team.Mascot;
             newTeam.Coach = team.Coach;
             newTeam.Owner = team.Owner;
             newTeam.AvgSalary = team.AvgSalary;
             newTeam.Active = team.Active;
             newTeam.Convictions = team.Convictions;
             newTeam.VenueId = team.VenueId;
             newTeam.YearId = team.YearId;
             newTeam.Championships = team.Championships;
             teamList.Add(newTeam);
         }
     }
     return teamList;
 }