public async Task <HumanInfoChangeResponse> CreateAsync(UserInfo user, HumanInfoChangeRequest humanInfoChangeRequest, CancellationToken cancellationToken = default(CancellationToken)) { if (user == null) { throw new ArgumentNullException(nameof(user)); } if (humanInfoChangeRequest == null) { throw new ArgumentNullException(nameof(humanInfoChangeRequest)); } return(_mapper.Map <HumanInfoChangeResponse>(await Store.CreateAsync(user, _mapper.Map <HumanInfoChange>(humanInfoChangeRequest), cancellationToken))); }
public async Task <HumanInfoChangeResponse> UpdateAsync(UserInfo user, string id, HumanInfoChangeRequest humanInfoChangeRequest, CancellationToken cancellationToken = default(CancellationToken)) { if (user == null) { throw new ArgumentNullException(nameof(user)); } if (humanInfoChangeRequest == null) { throw new ArgumentNullException(nameof(humanInfoChangeRequest)); } var humanInfoChange = _mapper.Map <HumanInfoChange>(humanInfoChangeRequest); humanInfoChange.Id = id; return(_mapper.Map <HumanInfoChangeResponse>(await Store.UpdateAsync(user, humanInfoChange, cancellationToken))); }
public async Task <ResponseMessage <HumanInfoChangeResponse> > CreateHumanInfoChange(UserInfo user, [FromBody] HumanInfoChangeRequest humanInfoChangeRequest) { Logger.Trace($"用户{user?.UserName ?? ""}({user?.Id ?? ""})新增人事变动信息(CreateHumanInfoChange),请求体为:\r\n" + (humanInfoChangeRequest != null ? JsonHelper.ToJson(humanInfoChangeRequest) : "")); ResponseMessage <HumanInfoChangeResponse> response = new ResponseMessage <HumanInfoChangeResponse>(); if (!ModelState.IsValid) { response.Code = ResponseCodeDefines.ModelStateInvalid; response.Message = ModelState.GetAllErrors(); Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})新增人事变动信息(CreateHumanInfoChange)模型验证失败:{response.Message}请求体为:\r\n" + (humanInfoChangeRequest != null ? JsonHelper.ToJson(humanInfoChangeRequest) : "")); return(response); } try { response.Extension = await _humanInfoChangeManager.CreateAsync(user, humanInfoChangeRequest, HttpContext.RequestAborted); } catch (Exception e) { response.Code = ResponseCodeDefines.ServiceError; response.Message = e.Message; Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})新增人事变动信息(CreateHumanInfoChange)失败:{response.Message}请求体为:\r\n" + (humanInfoChangeRequest != null ? JsonHelper.ToJson(humanInfoChangeRequest) : "")); } return(response); }