public async Task <HttpResponseMessage> GetVehicleInfo([FromUri] GetCarVehicleRequest request) { _logAppInfo.Info(string.Format("获取车型信息接口请求串:{0}", Request.RequestUri)); var viewModel = new CarVehicleInfoNewViewModel(); if (!ModelState.IsValid) { viewModel.BusinessStatus = -10000; string msg = ModelState.Values.Where(item => item.Errors.Count == 1).Aggregate(string.Empty, (current, item) => current + (item.Errors[0].ErrorMessage + "; ")); viewModel.StatusMessage = "输入参数错误," + msg; return(viewModel.ResponseToJson()); } viewModel = await _appAchieveService.GetVehicleInfo(request, Request.GetQueryNameValuePairs(), Request.RequestUri); //_logAppInfo.Info(string.Format("获取车辆出险信息接口返回值:{0}", viewModel.ToJson())); return(viewModel.ResponseToJson()); }
public async Task <CarVehicleInfoNewViewModel> GetVehicleInfo(GetCarVehicleRequest request, IEnumerable <KeyValuePair <string, string> > pairs, Uri uri) { var viewModel = new CarVehicleInfoNewViewModel(); #region 参数校验 //校验请求串 var baseRequest = new AppBaseRequest() { Agent = request.Agent, SecCode = request.SecCode, CustKey = request.CustKey, BhToken = request.BhToken, ChildAgent = request.ChildAgent }; //校验返回值 var baseResponse = _appVerifyService.Verify(baseRequest, pairs); if (baseResponse.ErrCode != 1) { viewModel.BusinessStatus = baseResponse.ErrCode; viewModel.StatusMessage = baseResponse.ErrMsg; return(viewModel); } #endregion #region 业务逻辑 //拼接请求串 string strUrl = string.Format("http://{0}:{1}/api/CarInsurance/GetVehicleInfo", uri.Host, uri.Port); //3,续保请求 BaseResponse rep = await SimulateGet(strUrl, pairs); if (rep.ErrCode == 1) { viewModel = rep.ErrMsg.FromJson <CarVehicleInfoNewViewModel>(); } else { viewModel.BusinessStatus = rep.ErrCode; viewModel.StatusMessage = rep.ErrMsg; } #endregion return(viewModel); }