Example #1
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="car">实体对象</param>
        /// <returns></returns>
        public override int Insert(CarBrandEntity car)
        {
            int id   = 0;
            var list = this.QueryList(car);

            if (list.Any())
            {
                car.BrandLogo = list[0].BrandLogo;
                this.Update(car);
                id = list[0].Id;
            }
            else
            {
                id = CarDataAccess.Insert(
                    "INSERT INTO hengtu_carbrand(rid,url,brand,logo,tagname,add_time)VALUES(@Rid,@Url,@BrandName,@BrandLogo,@TagName,@AddTime)",
                    new
                {
                    car.Rid,
                    car.Url,
                    car.BrandName,
                    car.BrandLogo,
                    car.AddTime
                });
            }
            ShowInfoEventHandler?.Invoke(this, new ViewModelArg <CarBrandEntity> {
                Car = car, Type = list.Any() ? 0 : 1
            });
            return(car.Id = id);
        }
Example #2
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="car">实体对象</param>
        /// <returns></returns>
        public override int Insert(CarSeriesEntity car)
        {
            int id   = 0;
            var list = this.QueryList(car);

            if (list.Any())
            {
                this.Update(car);
                id = list[0].Id;
            }
            else
            {
                id = CarDataAccess.Insert(
                    "INSERT INTO hengtu_carmodeldetail(modelid,model,linkurl,reference_price,full_payment_reference,msrp,add_time)" +
                    "VALUES(@ModelId,@SeriesName,@LinkUrl,@ReferencePrice,@FullPaymentReference,@Msrp,@AddTime)",
                    new
                {
                    car.ModelId,
                    car.SeriesName,
                    car.LinkUrl,
                    car.ReferencePrice,
                    car.FullPaymentReference,
                    car.Msrp,
                    DateTime.Now,
                });
            }
            ShowInfoEventHandler?.Invoke(this, new ViewModelArg <CarSeriesEntity> {
                Car = car, Type = list.Any() ? 0 : 1
            });
            return(car.Id = id);
        }
Example #3
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="car">实体对象</param>
        /// <returns></returns>
        public override int Insert(CarModelEntity car)
        {
            int id   = 0;
            var list = this.QueryList(car);

            if (list.Any())
            {
                car.ModelName = list[0].ModelName;
                this.Update(car);
                id = list[0].Id;
            }
            else
            {
                id = CarDataAccess.Insert(
                    "INSERT INTO hengtu_carmodel(brandid,model,linkurl,factory,image,add_time,national_reference_price,msrp,second_hand,displacement,fuel_consumption,gearbox,warranty)" +
                    "VALUES(@BrandId,@ModelName,@LinkUrl,@Factory,@ImagePath,@AddTime,@NationalReferencePrice,@Msrp,@SecondHand,@Displacement,@FuelConsumption,@Gearbox,@Warranty)",
                    new
                {
                    car.BrandId,
                    car.ModelName,
                    car.LinkUrl,
                    car.Factory,
                    car.ImagePath,
                    car.AddTime,
                    car.NationalReferencePrice,
                    car.Msrp,
                    car.SecondHand,
                    car.Displacement,
                    car.FuelConsumption,
                    car.Gearbox,
                    car.Warranty
                });
            }
            ShowInfoEventHandler?.Invoke(this, new ViewModelArg <CarModelEntity> {
                Car = car, Type = list.Any() ? 0 : 1
            });
            return(car.Id = id);
        }