コード例 #1
0
        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));
        }
コード例 #2
0
 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());
 }
コード例 #3
0
        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));
        }
コード例 #4
0
        public IActionResult UpdateStudent([FromBody] StudentUpdateViewModel vm)
        {
            studentService.UpdateStudent(vm);

            return(Ok());
        }
コード例 #5
0
 public void UpdateStudent(StudentUpdateViewModel vm)
 {
     DatabaseProvider.UpdateStudent(vm.Id, vm.FirstName, vm.LastName, vm.MiddleName, vm.Group, vm.TeamId);
 }
コード例 #6
0
        public ActionResult StudentsUpdate(StudentUpdateViewModel model)
        {
            var ajaxResponse = _studentModel.StudentUpdate(model);

            return(Json(ajaxResponse));
        }