Example #1
0
        public Teacher Update(UpdateteacherViewModel viewModel)
        {
            Teacher teacher = new Teacher
            {
                Name              = viewModel.Name,
                SecondName        = viewModel.SecondName,
                Salary            = viewModel.Salary,
                YearsOfExperience = viewModel.YearsOfExperience,
                Position          = _positionFactory.GetPosition(DefaultPositions.Teacher)
            };

            return(teacher);
        }
Example #2
0
        public Teacher Update(UpdateteacherViewModel teacher)
        {
            var dbTeacher = _context.Teachers.SingleOrDefault(t => t.Id == teacher.Id);

            dbTeacher.Name              = teacher.Name;
            dbTeacher.SecondName        = teacher.SecondName;
            dbTeacher.Salary            = teacher.Salary;
            dbTeacher.YearsOfExperience = teacher.YearsOfExperience;
            var proxy = _proxyFactory.Get(dbTeacher.Id);
            var group = _context.Groups.SingleOrDefault(g => g.Id == teacher.GroupId);

            _context.SaveChanges();
            return(dbTeacher);
        }
Example #3
0
        public UpdateteacherViewModel UpdateViewModel(Teacher teacher)
        {
            UpdateteacherViewModel viewModel = new UpdateteacherViewModel
            {
                Name              = teacher.Name,
                SecondName        = teacher.SecondName,
                Salary            = teacher.Salary,
                YearsOfExperience = teacher.YearsOfExperience,
                SectionName       = teacher.SectionName,
                GroupId           = teacher.GroupId,
                Groups            = _context.Groups.Where(g => g.SectionId == teacher.SectionId).ToList()
            };

            return(viewModel);
        }