public static ProfessorViewModel ToViewModel(this Professor that)
        {
            var result = new ProfessorViewModel();

            var studentVmDic = that.Subjects.SelectMany(a => a.Students)
                .GroupBy(a => a.Id)
                .ToDictionary(a => a.Key, a => new StudentViewModel());
            var subjecVmtDic = that.Subjects.ToDictionary(a => a.Id, a => new SubjectViewModel());
            var marksVmDic =
                that.Subjects.SelectMany(a => a.Students)
                    .SelectMany(a => a.Marks)
                    .GroupBy(a => a.Id)
                    .ToDictionary(a => a.Key, a => new MarkViewModel());

            var studentDic = that.Subjects.SelectMany(a => a.Students)
                .GroupBy(a => a.Id)
                .ToDictionary(a => a.Key, a => a.FirstOrDefault());
            var subjectDic = that.Subjects.ToDictionary(a => a.Id, a => a);
            var marksDic =
                that.Subjects.SelectMany(a => a.Students)
                    .SelectMany(a => a.Marks)
                    .GroupBy(a => a.Id)
                    .ToDictionary(a => a.Key, a => a.FirstOrDefault());

            var professorVmDic = new Dictionary<string, ProfessorViewModel>
            {
                [that.Id] = result
            };
            var professorDic = new Dictionary<string, Professor>
            {
                [that.Id] = that
            };

            InitData(professorVmDic, studentVmDic, subjecVmtDic, marksVmDic,
                professorDic, studentDic, subjectDic, marksDic);

            return result;
        }
 public ActionResult AddMarkForStudent(ProfessorViewModel vm)
 {
     return PartialView("_editProfessor", vm);
 }
        public ActionResult EditProfessor(ProfessorViewModel vm)
        {
            var student = ProfessorRepository.GetProfessorById(vm.ProfessorId);
            student.Name = vm.Name;
            student.Surname = vm.Surname;
            ProfessorRepository.SaveChanges();

            return PartialView("_editProfessor", vm);
        }