Exemple #1
0
        public IWsModel <ReqCar, List <ResCarConciseInfo> > BeforeTodayCars([FromBody] WsModel <ReqCar, List <ResCarConciseInfo> > model)
        {
            if (model == null)
            {
                return(new WsModel <ReqCar, List <ResCarConciseInfo> >().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.IndexCarId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数IndexCarId为空"));
            }
            var begintime = DateTime.Today;
            var endtime   = DateTime.Today.AddDays(1).AddSeconds(-1);
            var pageParam = new PageParam(model.Request.PageSize, begintime, endtime);
            var ret       = new DBsCar().GetBeforeTodayCars(pageParam, model.Request.IndexCarId);

            if (ret == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            return(model.Ok(ret));
        }
Exemple #2
0
        public IWsModel <ReqCar, List <ResCarConciseInfo> > BeforeUserCars([FromBody] WsModel <ReqCar, List <ResCarConciseInfo> > model)
        {
            if (model == null)
            {
                return(new WsModel <ReqCar, List <ResCarConciseInfo> >().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.IndexCarId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数IndexCarId为空"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.OpenId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数OpenId为空"));
            }
            var pageParam = new PageParam(model.Request.PageSize, model.Request.SortType, model.Request.Ascending);
            var ret       = new DBsCar().GetBeforeUserCars(model.Request.OpenId, model.Request.CarSell, pageParam, model.Request.IndexCarId);

            if (ret == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            return(model.Ok(ret));
        }
Exemple #3
0
        public IWsModel <ReqCar, List <ResBrand> > BrandHot([FromBody] WsModel <ReqCar, List <ResBrand> > model)
        {
            if (model == null)
            {
                return(new WsModel <ReqCar, List <ResBrand> >().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            var pageParam = new PageParam(model.Request.PageSize);
            var ret       = new DBsCar().GetBrandHot(ValidityState.Enabled, pageParam);

            if (ret == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            var result = new List <ResBrand>();

            foreach (var item in ret)
            {
                result.Add(new ResBrand(item));
            }
            return(model.Ok(result));
        }
Exemple #4
0
        public IWsModel <ReqCar, List <ResBrand> > BrandSeries([FromBody] WsModel <ReqCar, List <ResBrand> > model)
        {
            if (model == null)
            {
                return(new WsModel <ReqCar, List <ResBrand> >().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.BrandId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数BrandId为空"));
            }
            var ret = new DBsCar().GetBrandSeries(model.Request.BrandId, ValidityState.Enabled);

            if (ret == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            var result = new List <ResBrand>();

            foreach (var item in ret)
            {
                result.Add(new ResBrand(item));
            }
            return(model.Ok(result));
        }
Exemple #5
0
        public IWsModel <ReqCar, List <ResGroupBrand> > BrandAll([FromBody] WsModel <ReqCar, List <ResGroupBrand> > model)
        {
            if (model == null)
            {
                return(new WsModel <ReqCar, List <ResGroupBrand> >().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            // var ret = new DBsCar().GetAllBrand(ValidityState.Enabled);

            var ret = new DBsCar().GetGroupBrand(ValidityState.Enabled);

            if (ret == null || ret.Count(i => i != null) == 0)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "品牌分组不存在"));
            }
            foreach (var item in ret)
            {
                var list = new DBsCar().GetGroupBrandList(ValidityState.Enabled, item.Capital);
                if (ret != null && ret.Count(i => i != null) > 0)
                {
                    item.Values = list;
                }
            }
            return(model.Ok(ret));
        }
Exemple #6
0
        public IWsModel <ReqAddSeries, ResBrand> AddCarSeries([FromBody] WsModel <ReqAddSeries, ResBrand> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqAddSeries, ResBrand>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (!model.Request.Valid4Enum())
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "枚举参数无效"));
            }
            if (!model.Request.Valid4AddSeries())
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "参数无效"));
            }
            var dbscar = new DBsCar();

            if (dbscar.GetBrandSeriesDetail(model.Request.ParentId, ValidityState.Enabled) == null)
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "参数ParentId无效"));
            }
            var carBrand  = new CarsBrandSeries(model.Request.ParentId, model.Request.Name, ValidityState.Enabled, model.Request.SeriesGrade);
            var retDetail = new DBaCar().AddBrandSeries(carBrand);

            if (retDetail == 0)
            {
                return(model.Fail(ErrorCode.DB_SAVE_FAILED, "添加失败"));
            }
            var ret = new ResBrand(carBrand);

            return(model.Ok(ret));
        }
Exemple #7
0
        public IWsModel <ReqAddCar, ResCarConciseInfo> AddCarInfo([FromBody] WsModel <ReqAddCar, ResCarConciseInfo> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqAddCar, ResCarConciseInfo>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (!model.Request.Valid4Enum())
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "枚举参数无效"));
            }
            if (!model.Request.Valid4AddCar())
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "参数无效"));
            }
            var dbscar = new DBsCar();

            if (dbscar.GetBrandSeriesDetail(model.Request.BrandId, ValidityState.Enabled) == null)
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "参数BrandId无效"));
            }
            if (dbscar.GetBrandSeriesDetail(model.Request.SeriesId, ValidityState.Enabled) == null)
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "参数SeriesId无效"));
            }
            var dbsaccount = new DbsAccount();

            if (dbsaccount.ByOpenId(model.Request.AccountId, ValidityState.Enabled) == null)
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "参数AccountId无效"));
            }
            if (dbsaccount.GetCorporationInfo(model.Request.CorporationId, ValidityState.Enabled) == null)
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "参数CorporationId无效"));
            }
            var carDetail = new CarsDetails(model.Request.CarDrive, model.Request.CarEnergy, model.Request.CarGearbox, model.Request.CarSeat,
                                            model.Request.CarEmissionStandard, model.Request.Appearance, model.Request.Interior, model.Request.CarConfig, model.Request.CarLicenseTime, model.Request.CarAge,
                                            model.Request.Mileage, model.Request.Emission, model.Request.Images);
            var retDetail = new DBaCar().AddCarDetail(carDetail);

            if (retDetail == 0)
            {
                return(model.Fail(ErrorCode.DB_SAVE_FAILED, "添加失败"));
            }
            var carConcise = new CarsConcise(model.Request.AccountId, carDetail.Id, model.Request.CorporationId, model.Request.Name, model.Request.BrandId, model.Request.SeriesId, model.Request.GuidePrice,
                                             model.Request.SellingPrice, model.Request.BasePrice, ValidityState.Enabled, (carDetail.Images == null)?"":carDetail.Images[0], CarSell.Sale, model.Request.CarActivity);
            var retConcise = new DBaCar().AddCarConcise(carConcise);

            if (retConcise == 0)
            {
                return(model.Fail(ErrorCode.DB_SAVE_FAILED, "添加失败"));
            }
            var ret = new ResCarConciseInfo(carConcise, carDetail.CarLicenseTime, carDetail.Mileage);

            return(model.Ok(ret));
        }
Exemple #8
0
        public IWsModel <ReqAddCar, ResCarConciseInfo> UpdateCarInfo([FromBody] WsModel <ReqAddCar, ResCarConciseInfo> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqAddCar, ResCarConciseInfo>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (!model.Request.Valid4Enum())
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "枚举参数无效"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.CarInfoId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            var carconcise = new DBsCar().GetCarInfo(model.Request.CarInfoId, ValidityState.Enabled);

            if (carconcise == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            var cardetail = new DBsCar().GetCarDetail(carconcise.CarsDetailsId);

            if (carconcise == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            if (AlterModel(ref cardetail, model.Request))
            {
                var retDetail = new DBaCar().UpdateCarDetail(cardetail);
                if (retDetail == 0)
                {
                    return(model.Fail(ErrorCode.DB_SAVE_FAILED, "修改失败"));
                }
            }
            if (AlterModel(ref carconcise, model.Request))
            {
                var retConcise = new DBaCar().UpdateCarConcise(carconcise);
                if (retConcise == 0)
                {
                    return(model.Fail(ErrorCode.DB_SAVE_FAILED, "修改失败"));
                }
            }
            var ret = new ResCarConciseInfo(carconcise, cardetail.CarLicenseTime, cardetail.Mileage);

            return(model.Ok(ret));
        }
Exemple #9
0
        public IWsModel <ReqCar, List <ResCarConciseInfo> > LaterFilterCars([FromBody] WsModel <ReqCar, List <ResCarConciseInfo> > model)
        {
            if (model == null)
            {
                return(new WsModel <ReqCar, List <ResCarConciseInfo> >().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            var pageParam = new PageParam(model.Request.PageSize, model.Request.SortType, model.Request.Ascending);
            var ret       = new DBsCar().GetLaterFilterCars(pageParam, model.Request.IndexCarId, model.Request.BrandId, model.Request.SeriesId, model.Request.CarActivity,
                                                            model.Request.SeriesGrade, model.Request.BrandCountry, model.Request.CarDrive, model.Request.CarEnergy, model.Request.CarGearbox, model.Request.CarSeat);

            if (ret == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            return(model.Ok(ret));
        }
Exemple #10
0
        public IWsModel <ReqCar, ResCarDetail> CarInfo([FromBody] WsModel <ReqCar, ResCarDetail> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqCar, ResCarDetail>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.CarId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数CarId为空"));
            }
            var ret = new DBsCar().GetCarDetailToRes(model.Request.CarId);

            if (ret == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            return(model.Ok(ret));
        }
Exemple #11
0
        public IWsModel <ReqAddSeries, ResBrand> UpdateCarSeries([FromBody] WsModel <ReqAddSeries, ResBrand> model)
        {
            if (model == null)
            {
                return(new WsModel <ReqAddSeries, ResBrand>().Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (model.Request == null)
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            if (!model.Request.Valid4Enum())
            {
                return(model.Fail(ErrorCode.PARAM_INVALID, "枚举参数无效"));
            }
            if (string.IsNullOrWhiteSpace(model.Request.CarSeriesId))
            {
                return(model.Fail(ErrorCode.PARAM_NULL, "参数为空"));
            }
            var carSeries = new DBsCar().GetBrandSeriesDetail(model.Request.CarSeriesId);

            if (carSeries == null)
            {
                return(model.Fail(ErrorCode.DB_NOTEXISTED, "数据不存在"));
            }
            if (AlterModel(ref carSeries, model.Request))
            {
                var retDetail = new DBaCar().UpdateBrandSeries(carSeries);
                if (retDetail == 0)
                {
                    return(model.Fail(ErrorCode.DB_SAVE_FAILED, "修改失败"));
                }
            }
            var ret = new ResBrand(carSeries);

            return(model.Ok(ret));
        }