public async Task <IActionResult> Student_Update([FromBody] StudentUpdateViewModel viewModel) { var student = await _Context.Students.FirstOrDefaultAsync(v => v.ID == UserID); if (student == null) { throw new ValidatorException("不存在该用户"); } StudentUpdateIntegrationEvent @event = null; if (viewModel.Password != null) { student.Password = MD5Builder.Builder32Hash(viewModel.Password); } if (viewModel.Picture != null) { student.Picture = viewModel.Picture; } if (viewModel.NickName != null) { student.NickName = viewModel.NickName; @event = new StudentUpdateIntegrationEvent(UserID, viewModel.NickName); } using (var trans = _Context.Database.BeginTransaction(_CapPublisher, autoCommit: true)) { if (@event != null) { await _CapPublisher.PublishAsync("ELearn.UserCenter.StudentUpdate", @event); } } return(Json(true)); }
public IActionResult StudentUpdate(StudentUpdateViewModel model) { if (ModelState.IsValid) { Student student = _repository.GetById(model.Id); student.Name = model.Name; student.Email = model.Email; student.Batch = model.Batch; student.Dept = model.Dept; _repository.Update(student); return(RedirectToAction("StudentDetails", new { id = student.Id })); } return(View()); }
public IActionResult StudentUpdate(int id) { Student student = _repository.GetById(id); StudentUpdateViewModel studentUpdateViewModel = new StudentUpdateViewModel { Id = student.Id, Name = student.Name, Batch = student.Batch, Dept = student.Dept, Email = student.Email, }; return(View(studentUpdateViewModel)); }
public IActionResult UpdateStudent([FromBody] StudentUpdateViewModel vm) { studentService.UpdateStudent(vm); return(Ok()); }
public void UpdateStudent(StudentUpdateViewModel vm) { DatabaseProvider.UpdateStudent(vm.Id, vm.FirstName, vm.LastName, vm.MiddleName, vm.Group, vm.TeamId); }
public ActionResult StudentsUpdate(StudentUpdateViewModel model) { var ajaxResponse = _studentModel.StudentUpdate(model); return(Json(ajaxResponse)); }