public ActionResult UpdateUserInfo(UpdateUserInfoModel model) { var userInfo = BLLSession.IUserService.GetModel(m => m.UserID == CurrentUser.UserID); userInfo.UserName = model.UserName; userInfo.DepartmentType = model.DepartmentType; BLLSession.IUserService.ModifyModel(userInfo); //重新保存信息到Session和写入到Cookies WebHelper.OperateContext.Current.SetUserToSessionAndCookies(userInfo, true); return(Redirect("/admin")); }
public async Task <IActionResult> UpdateUserInfoAsync([FromBody] UpdateUserInfoModel updateModel) { try { var updateResult = await _accountService.UpdateInfoAsync(updateModel); return(updateResult ? (IActionResult)NoContent() : BadRequest()); } catch (Exception e) { return(StatusCode((int)HttpStatusCode.InternalServerError, new ErrorResponseModel(e.Message))); } }
public ActionResult UpdateUserInfo() { if (!OperateHelper.IsLogin()) { return(View()); } var userInfo = BLLSession.IUserService.GetListBy(m => m.UserID == CurrentUser.UserID).FirstOrDefault(); UpdateUserInfoModel model = new UpdateUserInfoModel(); model.UserName = userInfo.UserName; model.DepartmentType = userInfo.DepartmentType; return(View(model)); }
public bool UpdateInfo(UpdateUserInfoModel model) { ExceptionHelper.ThrowIfNull(model, nameof(model)); bool isUpdate = false; if (!string.IsNullOrWhiteSpace(model.Name)) { _LazyValue.Value.name = model.Name; isUpdate = true; } if (!string.IsNullOrWhiteSpace(model.AreaNo)) { _LazyValue.Value.areaNo = model.AreaNo; isUpdate = true; } if (!string.IsNullOrWhiteSpace(model.Company)) { _LazyValue.Value.company = model.Company; isUpdate = true; } if (!string.IsNullOrWhiteSpace(model.Job)) { _LazyValue.Value.job = model.Job; isUpdate = true; } if (model.Sex.HasValue) { _LazyValue.Value.sex = model.Sex.Value; isUpdate = true; } if (!string.IsNullOrWhiteSpace(model.VerifyImage)) { _LazyValue.Value.verifyImage = model.VerifyImage; isUpdate = true; } if (isUpdate) { if (_LazyValue.Value.verifyStatus == VerifyStatus.Pass) { _LazyValue.Value.isNeedVerify = true; } _UserRepository.SaveChanges(); } return(isUpdate); }
public async Task <bool> UpdateInfoAsync(UpdateUserInfoModel updateModel) { var user = await _context.Users.FindAsync(_currentUser.Id); if (user == null) { return(false); } user.Email = updateModel.Email; user.Birthday = updateModel.Birthday; user.PhoneNumber = updateModel.PhoneNumber; user.FirstName = updateModel.FirstName; user.LastName = updateModel.LastName; await _context.SaveChangesAsync(); return(true); }
private UpdateUserInfoModel UpdateUserInfoMethod(UpdateUserInfoParamModel paramModel) { var model = new UpdateUserInfoModel(); try { var userInfo = _userInfoService.GetByOpenId(paramModel.OpenId); var userInfoId = 0; if (userInfo != null) { userInfo.NickName = paramModel.NickName; userInfo.AvatarUrl = paramModel.AvatarUrl; userInfo.OpenId = paramModel.OpenId; if (!string.IsNullOrEmpty(paramModel.FormId)) { userInfo.FormId = paramModel.FormId; userInfo.FormIdExpireTime = DateTime.Now.AddDays(7).AddMinutes(-2); } if (!string.IsNullOrEmpty(paramModel.Mobile)) { userInfo.Mobile = paramModel.Mobile; } _userInfoService.Update(userInfo); userInfoId = userInfo.Id; } else { var newUserInfo = new UserInfo { NickName = paramModel.NickName, AvatarUrl = paramModel.AvatarUrl, OpenId = paramModel.OpenId }; if (!string.IsNullOrEmpty(paramModel.FormId)) { newUserInfo.FormId = paramModel.FormId; newUserInfo.FormIdExpireTime = DateTime.Now.AddDays(7).AddMinutes(-2); } if (!string.IsNullOrEmpty(paramModel.Mobile)) { newUserInfo.Mobile = paramModel.Mobile; } _userInfoService.Insert(newUserInfo); userInfoId = newUserInfo.Id; } model.NickName = paramModel.NickName; model.AvatarUrl = paramModel.AvatarUrl; model.OpenId = paramModel.OpenId; model.Mobile = paramModel.Mobile; model.FormId = paramModel.FormId; model.FormIdExpireTime = !string.IsNullOrEmpty(model.FormId) ? DateTime.Now.AddDays(7).AddMinutes(-2).ToString("yyyy-MM-dd HH:mm:ss") : null; model.UserInfoId = userInfoId; model.IsSuccess = true; model.ReturnMsg = "更新成功"; } catch (Exception ex) { model.IsSuccess = false; model.ReturnMsg = ex.Message; } return(model); }