public IActionResult TeamAddView()
        {
            using (var db = new Context())
            {
                var newTeam = new Team();
                newTeam.city   = Request.Form["city"];
                newTeam.name   = Request.Form["name"];
                newTeam.Clubid = int.Parse(Request.Form["idClub"]);
                db.Team.Add(newTeam);
                db.SaveChanges();

                var model = new ModelForClubView();
                db.Club.Load();
                db.SportCategory.Load();
                db.SportRang.Load();
                db.Sportsmen.Load();
                db.Team.Load();
                db.Trainer.Load();
                model.allClubs        = db.Club.ToList();
                model.selectClub      = newTeam.Clubid;
                model.sportsmenOnClub = db.Sportsmen.Where(x => x.Clubid == model.selectClub).ToList();
                model.teamOnClub      = db.Team.Where(x => x.Clubid == model.selectClub).ToList();
                model.trainerOnClub   = db.Trainer.Where(x => x.Clubid == model.selectClub).ToList();
                return(View("ClubView", model));
            }
        }
        public IActionResult TrainerAddView()
        {
            using (var db = new Context())
            {
                var newTrainer = new Trainer();
                newTrainer.job        = Request.Form["job"];
                newTrainer.name       = Request.Form["name"];
                newTrainer.surname    = Request.Form["surname"];
                newTrainer.patronymic = Request.Form["patronymic"];
                newTrainer.phone      = Request.Form["phone"].ToString();
                newTrainer.photo      = "";
                newTrainer.dateBirth  = Convert.ToDateTime(Request.Form["dateBirth"]);
                newTrainer.Clubid     = int.Parse(Request.Form["idClub"]);
                db.Trainer.Add(newTrainer);
                db.SaveChanges();

                var model = new ModelForClubView();
                db.Club.Load();
                db.SportCategory.Load();
                db.SportRang.Load();
                db.Sportsmen.Load();
                db.Team.Load();
                db.Trainer.Load();
                model.allClubs        = db.Club.ToList();
                model.selectClub      = newTrainer.Clubid;
                model.sportsmenOnClub = db.Sportsmen.Where(x => x.Clubid == model.selectClub).ToList();
                model.teamOnClub      = db.Team.Where(x => x.Clubid == model.selectClub).ToList();
                model.trainerOnClub   = db.Trainer.Where(x => x.Clubid == model.selectClub).ToList();
                return(View("ClubView", model));
            }
        }
 public IActionResult ClubInfoView(int id)
 {
     using (var db = new Context())
     {
         var model = new ModelForClubView();
         db.Club.Load();
         db.SportCategory.Load();
         db.SportRang.Load();
         db.Sportsmen.Load();
         db.Team.Load();
         db.Trainer.Load();
         model.allClubs        = db.Club.ToList();
         model.selectClub      = id;
         model.sportsmenOnClub = db.Sportsmen.Where(x => x.Clubid == model.selectClub).ToList();
         model.teamOnClub      = db.Team.Where(x => x.Clubid == model.selectClub).ToList();
         model.trainerOnClub   = db.Trainer.Where(x => x.Clubid == model.selectClub).ToList();
         return(View("ClubView", model));
     }
 }
 public IActionResult ClubView(int id)
 {
     using (var db = new Context())
     {
         var model = new ModelForClubView();
         //db.Category.Load();
         db.Club.Load();
         //db.Competition.Load();
         //db.Judge.Load();
         //db.JudgeCategory.Load();
         //db.JudgeCompetition.Load();
         // db.JudgePosition.Load();
         db.SportCategory.Load();
         db.SportRang.Load();
         db.Sportsmen.Load();
         db.Team.Load();
         db.Trainer.Load();
         //db.UnionRK.Load();
         model.allClubs = db.Club.ToList();
         if (id == -1)
         {
             model.selectClub      = db.Club.ToList()[0].id;
             model.sportsmenOnClub = db.Sportsmen.Where(x => x.Clubid == model.selectClub).ToList();
             model.teamOnClub      = db.Team.Where(x => x.Clubid == model.selectClub).ToList();
             model.trainerOnClub   = db.Trainer.Where(x => x.Clubid == model.selectClub).ToList();
             return(View(model));
         }
         else
         {
             model.selectClub      = id;
             model.sportsmenOnClub = db.Sportsmen.Where(x => x.Clubid == model.selectClub).ToList();
             model.teamOnClub      = db.Team.Where(x => x.Clubid == model.selectClub).ToList();
             model.trainerOnClub   = db.Trainer.Where(x => x.Clubid == model.selectClub).ToList();
             return(View(model));
         }
     }
 }
        public IActionResult TeamDelete(int id)
        {
            Team team = new Team();

            using (var db = new Context())
            {
                team = db.Team.FirstOrDefault(x => x.id == id);
                db.Team.Remove(team);
                db.SaveChanges();
                var model = new ModelForClubView();
                db.Club.Load();
                db.SportCategory.Load();
                db.SportRang.Load();
                db.Sportsmen.Load();
                db.Team.Load();
                db.Trainer.Load();
                model.allClubs        = db.Club.ToList();
                model.selectClub      = team.Clubid;
                model.sportsmenOnClub = db.Sportsmen.Where(x => x.Clubid == model.selectClub).ToList();
                model.teamOnClub      = db.Team.Where(x => x.Clubid == model.selectClub).ToList();
                model.trainerOnClub   = db.Trainer.Where(x => x.Clubid == model.selectClub).ToList();
                return(View("ClubView", model));
            }
        }