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)); }
/// <summary> /// 修改车辆详情 /// </summary> /// <param name="state"></param> /// <returns></returns> public long UpdateCarDetail(CarsDetails cd) { using (var dba = WxDbFactory.GetDbContext("hch_dba").MyDB) { var ret = dba.Update <CarsDetails>(cd); return(ret); } }
public IActionResult GetCarsDetails(CarsDetails cars) { Helpers.HttpContext.PostHttpAction(cars); var linkedListManual = GetLinkedList(cars.ListAgent); var firstAdded = linkedListManual.GetFirstAdded(); return(Json(firstAdded.data)); }
public static async void PostHttpAction(CarsDetails cars) { var json = JsonConvert.SerializeObject(cars); var data = new StringContent(json, Encoding.UTF8, "application/json"); var url = "http://localhost:65424/api/Car/PostMessage"; using var client = new HttpClient(); var response = await client.PostAsync(url, data); string result = response.Content.ReadAsStringAsync().Result; }
private bool AlterModel(ref CarsDetails entity, ReqAddCar am) { int sign = 0; if (!string.IsNullOrWhiteSpace(am.Appearance)) { entity.Appearance = am.Appearance; sign = 1; } if (!string.IsNullOrWhiteSpace(am.Interior)) { entity.Interior = am.Interior; sign = 1; } if (!string.IsNullOrWhiteSpace(am.CarConfig)) { entity.CarConfig = am.CarConfig; sign = 1; } if (am.CarLicenseTime != null) { entity.CarLicenseTime = am.CarLicenseTime; sign = 1; } if (am.CarAge != null) { entity.CarAge = am.CarAge; sign = 1; } if (am.Images != null && am.Images.Length != 0) { entity.Images = am.Images; sign = 1; } if (am.Mileage != 0) { entity.Mileage = am.Mileage; sign = 1; } if (am.Emission != 0) { entity.Emission = am.Emission; sign = 1; } if (Enum.IsDefined(typeof(CarDrive), am.CarDrive) && am.CarDrive != CarDrive.None) { entity.CarDrive = am.CarDrive; sign = 1; } if (Enum.IsDefined(typeof(CarEnergy), am.CarEnergy) && am.CarEnergy != CarEnergy.None) { entity.CarEnergy = am.CarEnergy; sign = 1; } if (Enum.IsDefined(typeof(CarGearbox), am.CarGearbox) && am.CarGearbox != CarGearbox.None) { entity.CarGearbox = am.CarGearbox; sign = 1; } if (Enum.IsDefined(typeof(CarSeat), am.CarSeat) && am.CarSeat != CarSeat.None) { entity.CarSeat = am.CarSeat; sign = 1; } if (Enum.IsDefined(typeof(CarEmissionStandard), am.CarEmissionStandard) && am.CarEmissionStandard != CarEmissionStandard.None) { entity.CarEmissionStandard = am.CarEmissionStandard; sign = 1; } return(sign == 1 ? true : false); }