private bool AlterModel(ref CarsBrandSeries entity, ReqAddSeries am) { int sign = 0; if (!string.IsNullOrWhiteSpace(am.Name)) { entity.Name = am.Name; sign = 1; } if (!string.IsNullOrWhiteSpace(am.ParentId)) { entity.ParentId = am.ParentId; sign = 1; } if (Enum.IsDefined(typeof(ValidityState), am.State) && am.State != ValidityState.None) { entity.State = am.State; sign = 1; } if (Enum.IsDefined(typeof(CarSeriesGrade), am.SeriesGrade) && am.SeriesGrade != CarSeriesGrade.None) { entity.SeriesGrade = am.SeriesGrade; sign = 1; } if (sign == 1) { entity.TimeStamp = DateTime.Now; } return(sign == 1 ? true : false); }
public IWsModel <ReqAddBrand, ResBrand> AddCarBrand([FromBody] WsModel <ReqAddBrand, ResBrand> model) { if (model == null) { return(new WsModel <ReqAddBrand, 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.Valid4AddBrand()) { return(model.Fail(ErrorCode.PARAM_INVALID, "参数无效")); } var carBrand = new CarsBrandSeries(model.Request.Name, model.Request.Capital, model.Request.BrandLogo, ValidityState.Enabled, model.Request.BrandType, model.Request.BrandCountry); 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)); }
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)); }
/// <summary> /// 修改品牌车系 /// </summary> /// <param name="state"></param> /// <returns></returns> public long UpdateBrandSeries(CarsBrandSeries cbs) { using (var dba = WxDbFactory.GetDbContext("hch_dba").MyDB) { var ret = dba.Update <CarsBrandSeries>(cbs); return(ret); } }
public int Build(IWxDbContext context, params string[] args) { using (var db = WxDbFactory.GetDbContext().MyDB) { if (db.Count <CarsBrandSeries>() == 0) { var Audi = new CarsBrandSeries("奥迪", "A", "ad.jpg", ValidityState.Enabled, CarBrandType.Hot, CarBrandCountry.Germany); var BMW = new CarsBrandSeries("宝马", "B", "bm.jpg", ValidityState.Enabled, CarBrandType.Hot, CarBrandCountry.Germany); var Benz = new CarsBrandSeries("奔驰", "B", "bc.jpg", ValidityState.Enabled, CarBrandType.Hot, CarBrandCountry.Germany); var Porsche = new CarsBrandSeries("保时捷", "B", "bsj.jpg", ValidityState.Enabled, CarBrandType.Hot, CarBrandCountry.Germany); var Bentley = new CarsBrandSeries("宾利", "B", "bl.jpg", ValidityState.Enabled, CarBrandType.Hot, CarBrandCountry.England); var Toyota = new CarsBrandSeries("丰田", "F", "ft.jpg", ValidityState.Enabled, CarBrandType.Hot, CarBrandCountry.Japanese); var Volkswagen = new CarsBrandSeries("大众", "D", "dz.jpg", ValidityState.Enabled, CarBrandType.Hot, CarBrandCountry.Germany); var Infiniti = new CarsBrandSeries("英菲尼迪", "Y", "yfnd.jpg", ValidityState.Enabled, CarBrandType.Hot, CarBrandCountry.Japanese); var Lexus = new CarsBrandSeries("雷克萨斯", "L", "lkss.jpg", ValidityState.Enabled, CarBrandType.Hot, CarBrandCountry.Japanese); var cbs = new List <CarsBrandSeries>() { Audi, BMW, Benz, Porsche, Bentley, Toyota, Volkswagen, Infiniti, Lexus }; var BrandSeries = new List <CarsBrandSeries>() { new CarsBrandSeries(Audi.Id, "A1(进口)", ValidityState.Enabled, CarSeriesGrade.Small), new CarsBrandSeries(Audi.Id, "A3", ValidityState.Enabled, CarSeriesGrade.Compact), new CarsBrandSeries(Audi.Id, "A4L", ValidityState.Enabled, CarSeriesGrade.Middle), new CarsBrandSeries(Audi.Id, "A6L", ValidityState.Enabled, CarSeriesGrade.MiddleLarge), new CarsBrandSeries(Audi.Id, "A8(进口)", ValidityState.Enabled, CarSeriesGrade.Large), new CarsBrandSeries(Audi.Id, "Q5", ValidityState.Enabled, CarSeriesGrade.SUV), new CarsBrandSeries(BMW.Id, "i3(进口)", ValidityState.Enabled, CarSeriesGrade.Small), new CarsBrandSeries(BMW.Id, "1系", ValidityState.Enabled, CarSeriesGrade.Compact), new CarsBrandSeries(BMW.Id, "3系", ValidityState.Enabled, CarSeriesGrade.Middle), new CarsBrandSeries(BMW.Id, "5系", ValidityState.Enabled, CarSeriesGrade.MiddleLarge), new CarsBrandSeries(BMW.Id, "5系(进口)", ValidityState.Enabled, CarSeriesGrade.MiddleLarge), new CarsBrandSeries(BMW.Id, "7系(进口)", ValidityState.Enabled, CarSeriesGrade.Large), new CarsBrandSeries(BMW.Id, "2系(进口)", ValidityState.Enabled, CarSeriesGrade.MPV), new CarsBrandSeries(Benz.Id, "SLC级(进口)", ValidityState.Enabled, CarSeriesGrade.SportsCar), new CarsBrandSeries(Benz.Id, "V级", ValidityState.Enabled, CarSeriesGrade.MPV), new CarsBrandSeries(Benz.Id, "GLA", ValidityState.Enabled, CarSeriesGrade.SUV), new CarsBrandSeries(Benz.Id, "GLC", ValidityState.Enabled, CarSeriesGrade.SUV), new CarsBrandSeries(Benz.Id, "E级", ValidityState.Enabled, CarSeriesGrade.MiddleLarge), new CarsBrandSeries(Benz.Id, "E级(进口)", ValidityState.Enabled, CarSeriesGrade.MiddleLarge), new CarsBrandSeries(Benz.Id, "S级(进口)", ValidityState.Enabled, CarSeriesGrade.Large), new CarsBrandSeries(Benz.Id, "R级(进口)", ValidityState.Enabled, CarSeriesGrade.MPV), }; db.InsertAll <CarsBrandSeries>(cbs); db.InsertAll <CarsBrandSeries>(BrandSeries); return(cbs.Count + BrandSeries.Count); } } return(0); }
private bool AlterModel(ref CarsBrandSeries entity, ReqAddBrand am) { int sign = 0; if (!string.IsNullOrWhiteSpace(am.Name)) { entity.Name = am.Name; sign = 1; } if (!string.IsNullOrWhiteSpace(am.Capital)) { entity.Capital = am.Capital; sign = 1; } if (!string.IsNullOrWhiteSpace(am.BrandLogo)) { entity.BrandLogo = am.BrandLogo; sign = 1; } if (Enum.IsDefined(typeof(ValidityState), am.State) && am.State != ValidityState.None) { entity.State = am.State; sign = 1; } if (Enum.IsDefined(typeof(CarBrandType), am.BrandType) && am.BrandType != CarBrandType.None) { entity.BrandType = am.BrandType; sign = 1; } if (Enum.IsDefined(typeof(CarBrandCountry), am.BrandCountry) && am.BrandCountry != CarBrandCountry.None) { entity.BrandCountry = am.BrandCountry; sign = 1; } if (sign == 1) { entity.TimeStamp = DateTime.Now; } return(sign == 1 ? true : false); }