public EditStudentViewModel(student student) { this.student = student; this.birthday = student.birthday; this.genderIndex = Gender.indexByValue(student.gender); this.firstname = student.firstname; this.lastname = student.lastname; this.kinshipIndex = Kinship.indexByValue(student.kinship); this.kinships = Kinship.list; this.genders = Gender.list; this.cmdEdit = new RelayCommand<object>(actEdit); }
public void actEditStudent(student student) { mediator.openEditStudentView(student); }
public void actDeleteStudent(student student) { mediator.openDeleteStudentView(student); }
public void openEditStudentView(student student) { EditStudentViewModel editStudentViewModel = new EditStudentViewModel(student); EditStudentView editStudentView = new EditStudentView(); editStudentView.DataContext = editStudentViewModel; editStudentViewModel.CloseActionEdit = new Action(() => editStudentView.Close()); editStudentView.Show(); }
public void openDeleteStudentView(student student) { DeleteStudentViewModel deleteStudentViewModel = new DeleteStudentViewModel(student); DeleteStudentView deleteStudentView = new DeleteStudentView(); deleteStudentView.DataContext = deleteStudentViewModel; deleteStudentViewModel.CloseActionDelete = new Action(() => deleteStudentView.Close()); deleteStudentView.ShowDialog(); }
public void actAdd(object o) { student student = new student(); bool error = false; this.validFirstname = new Validation(); this.validLastname = new Validation(); this.validGender = new Validation(); this.validBirthday = new Validation(); // Validation prénom if (!this.firstname.Equals("")) { student.firstname = this.firstname; this.validFirstname.message = "Valide"; this.validFirstname.valid = true; NotifyPropertyChanged("validFirstname"); } else { this.validFirstname.message = "Champ requis"; this.validFirstname.valid = false; NotifyPropertyChanged("validFirstname"); error = true; } // Validation nom if (!this.lastname.Equals("")) { student.lastname = this.lastname; this.validLastname.message = "Valide"; this.validLastname.valid = true; NotifyPropertyChanged("validLastname"); } else { this.validLastname.message = "Champ requis"; this.validLastname.valid = false; NotifyPropertyChanged("validLastname"); error = true; } // Validation date de naissance if (!this.birthday.Equals("")) { student.birthday = this.birthday; this.validBirthday.message = "Valide"; this.validBirthday.valid = true; NotifyPropertyChanged("validBirthday"); } else { this.validBirthday.message = "Champ requis"; this.validBirthday.valid = false; NotifyPropertyChanged("validBirthday"); error = true; } student.kinship = kinships.ElementAt(kinshipIndex).getValue(); student.birthday = birthday; student.gender = genders.ElementAt(genderIndex).getValue(); if (!error) { customer.students.Add(student); db.SaveChanges(); mediator.NotifyViewModel(Helper.Event.ADD_STUDENT, student); this.CloseActionAdd(); } }
public DeleteStudentViewModel(student student) { this.cmdDelete = new RelayCommand<Object>(actDeleteStudent); this.student = student; this.nbrRequest = student.requests.Count(); }