public ActionResult Create()
        {
            var model = new TeacherViewModel();

            model.Teacher = null;
            model.AvailableEducations = db.Educations;
            model.SelectedEducations = null;

            return View(model);
        }
        public ActionResult Create(TeacherViewModel result)
        {
            if (ModelState.IsValid)
            {
                List<Education> _educations = GetEducations(result.PostedEducations);
                result.Teacher.Educations = _educations;

                db.Teachers.Add(result.Teacher);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(result);
        }
        public ActionResult Edit(TeacherViewModel result)
        {
            //
            Teacher teacher = result.Teacher;
            List<Education> _educations = GetEducations(result.PostedEducations);

            if (ModelState.IsValid)
            {
                    Teacher _teacher = db.Teachers.FirstOrDefault(t => t.Id == teacher.Id);
                    _teacher.Name = teacher.Name;
                    _teacher.Username = teacher.Username;
                    _teacher.Role = teacher.Role;
                    //_teacher.Password = teacher.Password; // TODO move to action ChangePassword
                    Debug.WriteLine("_educations=" + _educations.Count);
                    if (_teacher.Educations != null)
                    {
                        _teacher.Educations.Clear();
                    }
                    _teacher.Educations = _educations;
                    Debug.WriteLine("educations=" + _teacher.Educations.Count);
                    db.Entry(_teacher).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
            }

                return RedirectToAction("index");
        }
        public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Teacher teacher = db.Teachers.Find(id);
            if (teacher == null)
            {
                return HttpNotFound();
            }

            var model = new TeacherViewModel();

            model.Teacher = teacher;
            model.AvailableEducations = db.Educations;
            model.SelectedEducations = teacher.Educations;

            return View(model);
        }