public ActionResult Edit(BranchChief branchChief, int[] selectedStudents)
        {
            BranchChief newBranch = db.BranchChieves.Find(branchChief.Id);

            newBranch.Name             = branchChief.Name;
            newBranch.LastName         = branchChief.LastName;
            newBranch.Age              = branchChief.Age;
            newBranch.Country          = branchChief.Country;
            newBranch.City             = branchChief.City;
            newBranch.Belt             = branchChief.Belt;
            newBranch.CountsStudent    = branchChief.CountPeople(selectedStudents);
            newBranch.YearStartTrainer = branchChief.YearStartTrainer;
            newBranch.JadgeCategory    = branchChief.JadgeCategory;
            newBranch.Rank             = branchChief.Rank;
            newBranch.NameBranch       = branchChief.NameBranch;
            newBranch.NationalRole     = branchChief.NationalRole;

            newBranch.KarateStudents.Clear();
            if (selectedStudents != null)
            {
                foreach (var s in db.KarateStudents.Where(ks => selectedStudents.Contains(ks.Id)))
                {
                    newBranch.KarateStudents.Add(s);
                }
            }
            db.Entry(newBranch).State = EntityState.Modified;
            db.SaveChanges();


            db.SaveChanges();
            return(RedirectToAction("ShowCoaches", "Coach"));
        }
        public ActionResult Edit(int id = 0)
        {
            ViewBag.KarateStudents = db.KarateStudents.ToList();
            Coach coach = db.Coaches.Find(id);

            if (coach == null)
            {
                BranchChief branchChief = db.BranchChieves.Find(id);
                return(View(branchChief));
            }

            return(View(coach));
        }
        public ActionResult Create(BranchChief branchChief, int[] selectedStudents)
        {
            if (selectedStudents != null)
            {
                foreach (var s in db.KarateStudents.Where(ks => selectedStudents.Contains(ks.Id)))
                {
                    branchChief.KarateStudents.Add(s);
                }
            }
            db.BranchChieves.Add(branchChief);

            branchChief.CountsStudent = branchChief.CountPeople(selectedStudents);

            db.SaveChanges();
            return(RedirectToAction("ShowCoaches", "Coach"));
        }