public ActionResult Edit()
        {
            TeacherControllerTeacherVM teacherModel = new TeacherControllerTeacherVM();
            Teacher teacher = new Teacher();
            TeacherRepository teacherRepo = new TeacherRepository();

            teacherModel.Id = AuthenticationManager.LoggedUser.Id;
            teacher = teacherRepo.GetById(teacherModel.Id);
            teacherModel.FirstName = teacher.FirstName;
            teacherModel.LastName = teacher.LastName;
            teacherModel.Password = teacher.Password;

            return View(teacherModel);
        }
 public ActionResult Edit(TeacherControllerTeacherVM teacherModel)
 {
     TryUpdateModel(teacherModel);
     if (ModelState.IsValid)
     {
         Teacher teacher = new Teacher();
         TeacherRepository teacherRepo = new TeacherRepository();
         teacher = teacherRepo.GetById(teacherModel.Id);
         teacher.FirstName = teacherModel.FirstName;
         teacher.LastName = teacherModel.LastName;
         teacher.Password = teacherModel.Password;
         teacherRepo.Save(teacher);
         return RedirectToAction("Index");
     }
     return View(teacherModel);
 }
 public ActionResult Index()
 {
     if (AuthenticationManager.LoggedUser == null || !AuthenticationManager.LoggedUser.GetType().BaseType.Equals(typeof(Teacher)))
     {
         return RedirectToAction("Login", "Default");
     }
     TeacherControllerTeacherVM model = new TeacherControllerTeacherVM();
     Teacher teacher = new Teacher();
     TeacherRepository teacherRepository = new TeacherRepository();
     teacher = teacherRepository.GetById(AuthenticationManager.LoggedUser.Id);
     model.FirstName = teacher.FirstName;
     model.LastName = teacher.LastName;
     CourseSubjectRepository courseSubjectRepository = new CourseSubjectRepository();
     CourseRepository courseRepository = new CourseRepository();
     SubjectRepository subjectRepository = new SubjectRepository();
     List<int> subjectList = new List<int>();
     Dictionary<string, List<Subject>> courseSubjectList = new Dictionary<string, List<Subject>>();
     List<Subject> subjects = new List<Subject>();
     List<int> courseList = new List<int>();
     foreach (var courseSubject in teacher.CourseSubject)
     {
         courseList.Add(courseSubject.Course.Id);
         subjectList.Add(courseSubject.Subject.Id);
     }
     subjectList = subjectList.Distinct().ToList();
     courseList = courseList.Distinct().ToList();
     Course course = new Course();
     foreach (var courseID in courseList)
     {
         course = courseRepository.GetById(courseID);
         subjects = courseSubjectRepository.GetAll(filter: c => c.Course.Id == courseID && subjectList.Contains(c.Subject.Id)).Select(s => s.Subject).ToList();
         courseSubjectList.Add(course.Name, subjects);
     }
     model.CourseSubjectList = courseSubjectList;
     return View(model);
 }