public PersonalInfoUpdateResponse Execute(PersonalInfoUpdateRequest request) { PersonalInfoUpdateResponse infoUpdateResponse = new PersonalInfoUpdateResponse(); UserInfo entity = ServiceHelper.LoadService <IUserService>().Get(request.UserId); entity.Name = request.Name; entity.Gender = request.Gender; ServiceHelper.LoadService <IUserService>().Update(entity); return(infoUpdateResponse); }
public XResult <PersonalInfoUpdateResponse> UpdateAccountInfo(PersonalInfoUpdateRequest request) { if (request == null) { return(new XResult <PersonalInfoUpdateResponse>(null, ErrorCode.INVALID_ARGUMENT, new ArgumentNullException(nameof(request)))); } if (!request.IsValid) { return(new XResult <PersonalInfoUpdateResponse>(null, ErrorCode.INVALID_ARGUMENT, new ArgumentException(request.ErrorMessage))); } String service = $"{this.GetType().FullName}.UpdateAccountInfo(...)"; var requestHash = $"update:{request.UID}".GetHashCode(); if (_lockProvider.Exists(requestHash)) { return(new XResult <PersonalInfoUpdateResponse>(null, ErrorCode.SUBMIT_REPEAT)); } try { if (!_lockProvider.Lock(requestHash)) { return(new XResult <PersonalInfoUpdateResponse>(null, ErrorCode.SUBMIT_REPEAT)); } var find = _personalSubAccountRepository.QueryProvider.FirstOrDefault(x => x.UID == request.UID); if (find == null) { return(new XResult <PersonalInfoUpdateResponse>(null, ErrorCode.INFO_NOT_EXIST, new ArgumentException("开户信息不存在"))); } Boolean hasChanged = false; if (String.Compare(find.Mobile, request.Mobile, true) != 0) { find.Mobile = request.Mobile; hasChanged = true; } if (String.Compare(find.Email, request.Email, true) != 0) { find.Email = request.Email; hasChanged = true; } if (!hasChanged) { return(new XResult <PersonalInfoUpdateResponse>(new PersonalInfoUpdateResponse() { Status = CommonStatus.SUCCESS.ToString(), Msg = CommonStatus.SUCCESS.GetDescription() })); } String traceMethod = "Bill99Util.Execute(/person/updateMember)"; _logger.Trace(TraceType.BLL.ToString(), CallResultStatus.OK.ToString(), service, traceMethod, LogPhase.BEGIN, "开始更新个人账户信息", request); var execResult = Bill99UtilYZT.Execute <PersonalInfoUpdateRequest, RawPersonalInfoUpdateResponse>("/person/updateMember", request); _logger.Trace(TraceType.BLL.ToString(), (execResult.Success ? CallResultStatus.OK : CallResultStatus.ERROR).ToString(), service, traceMethod, LogPhase.END, "结束更新个人账户信息", execResult.Value); if (!execResult.Success) { _logger.Error(TraceType.BLL.ToString(), CallResultStatus.ERROR.ToString(), service, traceMethod, "更新个人账户信息失败", execResult.FirstException, request); return(new XResult <PersonalInfoUpdateResponse>(new PersonalInfoUpdateResponse() { Status = CommonStatus.FAILURE.ToString(), Msg = CommonStatus.FAILURE.GetDescription() })); } _personalSubAccountRepository.Update(find); var saveResult = _personalSubAccountRepository.SaveChanges(); if (!saveResult.Success) { _logger.Error(TraceType.BLL.ToString(), CallResultStatus.ERROR.ToString(), service, traceMethod, "更新个人账户信息失败", saveResult.FirstException, request); return(new XResult <PersonalInfoUpdateResponse>(null, saveResult.FirstException)); } return(new XResult <PersonalInfoUpdateResponse>(new PersonalInfoUpdateResponse() { Status = CommonStatus.SUCCESS.ToString(), Msg = CommonStatus.SUCCESS.GetDescription() })); } finally { _lockProvider.UnLock(requestHash); } }