private void CreateEdit(object sender, EventArgs e) { if (!CheckInputFields()) { return; } if (_studentToEdit == null) { var newStudent = new Student { FirstName = firstNameTextBox.Text, LastName = lastNameTextBox.Text, Birthdate = birthdayDatePicker.Value.Date, Class = classComboBox.SelectedItem.ToString(), Gender = (maleRadioButton.Checked) ? Gender.Male : Gender.Female }; _studentsRepository.Add(newStudent); } else { _studentToEdit.FirstName = firstNameTextBox.Text; _studentToEdit.LastName = lastNameTextBox.Text; _studentToEdit.Birthdate = birthdayDatePicker.Value.Date; _studentToEdit.Gender = (maleRadioButton.Checked) ? Gender.Male : Gender.Female; _studentToEdit.Class = classComboBox.SelectedItem.ToString(); _studentsRepository.Edit(_studentToEdit); } Close(); }
public ActionResult Edit([Bind(Include = "id,RegistrationID,FirstName,SecondName,Email,PhoneNumber")] Student student) { if (ModelState.IsValid) { //db.Entry(student).State = EntityState.Modified; // db.SaveChanges(); db.Edit(student); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult Edit([Bind(Include = "StudentId,FirstName,LastName,CNP,Specialization,YearOfStudy")] StudentVM studentVM) { if (ModelState.IsValid) { Student student = StudentMap.StudentVMToStudent(studentVM); studentRepo.Edit(student); return(RedirectToAction("Index")); } return(View(studentVM)); }
internal Student Edit(Student update) { var exists = _repo.GetById(update.Id); if (exists == null) { throw new Exception("Invalid Id"); } // update.AuthorId = exists.AuthorId _repo.Edit(update); return(update); }