Ejemplo n.º 1
0
        public DriverLicenseTypeResponse GetList(GetDriverLicenseCarTypeRequest request, IEnumerable <KeyValuePair <string, string> > pairs)
        {
            DriverLicenseTypeResponse response = new DriverLicenseTypeResponse();

            //根据经纪人获取手机号
            IBxAgent agentModel = GetAgentModelFactory(request.Agent);

            if (!agentModel.AgentCanUse())
            {
                response.Status = HttpStatusCode.Forbidden;
                return(response);
            }
            //参数校验
            if (!ValidateReqest(pairs, agentModel.SecretKey, request.SecCode))
            {
                response.Status = HttpStatusCode.Forbidden;
                return(response);
            }
            var listskey = string.Format("gsc_driverlicense_cartype_key");
            var list     = CacheProvider.Get <List <bx_drivelicense_cartype> >(listskey);

            if (list == null)
            {
                list = _typeRepository.FindList();
                CacheProvider.Set(listskey, list, 86400);
            }
            response.List = list;

            return(response);
        }
Ejemplo n.º 2
0
        public HttpResponseMessage GetList([FromUri] GetDriverLicenseCarTypeRequest request)
        {
            DriverLicenseTypeViewModel viewModel = new DriverLicenseTypeViewModel();

            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());
            }

            DriverLicenseTypeResponse response = _driverLicenseTypeService.GetList(request, Request.GetQueryNameValuePairs());

            viewModel.Items = new List <DriverLicenseType>();
            if (response.Status == HttpStatusCode.BadRequest || response.Status == HttpStatusCode.Forbidden)
            {
                viewModel.BusinessStatus = -10001;
                viewModel.StatusMessage  = "参数校验错误,请检查您的校验码";
                return(viewModel.ResponseToJson());
            }

            if (response.Status == HttpStatusCode.ExpectationFailed)
            {
                viewModel.BusinessStatus = -10003;
                viewModel.StatusMessage  = "服务器发生异常";
                return(viewModel.ResponseToJson());
            }

            viewModel.Items          = response.List.ConvertToList();
            viewModel.BusinessStatus = 1;
            viewModel.StatusMessage  = "获取成功";

            return(viewModel.ResponseToJson());
        }