public void Insert(StudentDto student) { this.studentRepository.Insert(new Student { Id = Guid.NewGuid(), Name = student.Name, DateOfBirth = student.DateOfBirth, Address = student.Address, PhoneNumber = student.PhoneNumber }); this.studentRepository.SaveChange(); }
public IActionResult Edit(StudentDto model) { if (ModelState.IsValid) { if (model.Id != Guid.Empty && model.Id != null) { this.studentService.Update(model); } else { this.studentService.Insert(model); } } return View(model); }
public void Update(StudentDto studentDto) { var student = this.studentRepository.Get(studentDto.Id); student.Name = studentDto.Name; student.DateOfBirth = studentDto.DateOfBirth; student.Address = studentDto.Address; student.PhoneNumber = studentDto.PhoneNumber; this.studentRepository.Update(student); this.studentRepository.SaveChange(); }