public ActionResult DeleteConfirmed(int id)
 {
     using (var context = new FootballManagerDBContext())
     {
         Team team = context.Teams.Find(id);
         context.Teams.Remove(team);
         context.SaveChanges();
     }
     return RedirectToAction("Index");
 }
        public ActionResult Create(Team team)
        {
            if (ModelState.IsValid)
            {
                using (var context = new FootballManagerDBContext())
                {
                    context.Teams.Add(team);
                    context.SaveChanges();
                }
                return RedirectToAction("Index");
            }

            return View(team);
        }
        public ActionResult Create(Player player, String teamList)
        {
            var teamId = Convert.ToInt32(teamList);
            if (ModelState.IsValid)
            {
                using (var context = new FootballManagerDBContext())
                {
                    Team team = context.Teams.Single(selectedTeam => selectedTeam.ID == teamId);
                    player.Team = team;
                    player.TeamId = team.ID;
                    context.Players.Add(player);
                    context.SaveChanges();
                }
                return RedirectToAction("IndexList");
            }

            return View(player);
        }
        public ActionResult Create(Match match, string teamListHome, string teamListAway)
        {
            var teamHomeId = Convert.ToInt32(teamListHome);
            var teamAwayId = Convert.ToInt32(teamListAway);
            if (ModelState.IsValid)
            {
                using (var context = new FootballManagerDBContext())
                {
                    Team teamHome = context.Teams.Single(d => d.ID == teamHomeId);
                    Team teamAway = context.Teams.Single(d => d.ID == teamAwayId);
                    match.HomeTeamId = teamHomeId;
                    match.AwayTeamId = teamAwayId;
                    match.HomeTeamName = teamHome.Name;
                    match.AwayTeamName = teamAway.Name;
                    context.Matches.Add(match);
                    context.SaveChanges();
                }

                return RedirectToAction("Index");
            }

            return View(match);
        }
 public ActionResult DeleteConfirmed(int id)
 {
     Player player;
     using (var context = new FootballManagerDBContext())
     {
         player = context.Players.Find(id);
         context.Players.Remove(player);
         context.SaveChanges();
     }
     return RedirectToAction("IndexList");
 }
 public ActionResult Edit(Team team)
 {
     if (ModelState.IsValid)
     {
         using (var context = new FootballManagerDBContext())
         {
             context.Entry(team).State = EntityState.Modified;
             context.SaveChanges();
         }
         return RedirectToAction("Index");
     }
     return View(team);
 }
        public ActionResult DeleteConfirmed(int id)
        {
            using (var context = new FootballManagerDBContext())
            {
                Match match = context.Matches.Find(id);
                context.Matches.Remove(match);
                context.SaveChanges();
            }

            return RedirectToAction("Index");
        }