Exemplo n.º 1
0
        private void AddStudent(object parameter)
        {
            var studentViewModel = studentService.Create();

            if (studentViewModel == null)
            {
                return;
            }

            var student = MappingUtil.MapToInstance <StudentDTO, Student>(studentViewModel);

            studentRepository.Add(student);
            studentViewModel.Id = student.Id;
            Students.Add(studentViewModel);

            SelectedStudent = studentViewModel;
        }
Exemplo n.º 2
0
        private void EditSelectedStudent(object parameter)
        {
            if (SelectedStudent == null)
            {
                return;
            }

            var selectedStudentClone = (StudentDTO)SelectedStudent.Clone();
            var editResult           = studentService.Edit(selectedStudentClone);

            if (editResult)
            {
                SelectedStudent.FirstName = selectedStudentClone.FirstName;
                SelectedStudent.LastName  = selectedStudentClone.LastName;
                SelectedStudent.Age       = selectedStudentClone.Age;
                SelectedStudent.Gender    = selectedStudentClone.Gender;

                var student = MappingUtil.MapToInstance <StudentDTO, Student>(selectedStudent);
                studentRepository.Update(student);
            }
        }