Ejemplo n.º 1
0
        public HuoPing UpdateSingle(int id, HuoPingReq data)
        {
            HuoPing model = db.HuoPing.Find(id);

            SetHuoPing(model, data);
            db.SaveChanges();
            return(model);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 设置model,如果不为空就设置,如果为空则和之前一样
        /// </summary>
        /// <param name="target"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public HuoPing SetHuoPing(HuoPing model, HuoPingReq data)
        {
            if (!string.IsNullOrEmpty(data.Name))
            {
                model.Name = data.Name;
            }

            if (!string.IsNullOrEmpty(data.HuoPingImg))
            {
                model.HuoPingImg = data.HuoPingImg;
            }

            if (!string.IsNullOrEmpty(data.SingleDesc))
            {
                model.SingleDesc = data.SingleDesc;
            }
            if (data.SingleCount != null)
            {
                model.SingleCount = data.SingleCount.Value;
            }
            if (!string.IsNullOrEmpty(data.UseUnit))
            {
                model.UseUnit = data.UseUnit;
            }
            if (data.DayUseCount != null)
            {
                model.DayUseCount = data.DayUseCount.Value;
            }
            if (!string.IsNullOrEmpty(data.UseType))
            {
                model.UseType = data.UseType;
            }
            if (!string.IsNullOrEmpty(data.Mark))
            {
                model.Mark = data.Mark;
            }
            if (data.projectid != null)
            {
                model.projectid = data.projectid.Value;
            }
            if (!string.IsNullOrEmpty(data.ProjectName))
            {
                model.ProjectName = data.ProjectName;
            }
            if (data.OptId != null)
            {
                model.OptId = data.OptId.Value;
            }
            if (data.CreateDate != null && data.CreateDate != DateTime.MinValue && data.CreateDate != SqlDateTime.MinValue.Value)
            {
                model.CreateDate = data.CreateDate.Value;
            }
            if (!string.IsNullOrEmpty(data.OptName))
            {
                model.OptName = data.OptName;
            }
            if (data.SinglePrice != null)
            {
                model.SinglePrice = data.SinglePrice.Value;
            }
            if (!string.IsNullOrEmpty(data.Supplier))
            {
                model.Supplier = data.Supplier;
            }
            if (data.CurStock != null)
            {
                model.CurStock = data.CurStock.Value;
            }
            if (!string.IsNullOrEmpty(data.ValidState))
            {
                model.ValidState = data.ValidState;
            }
            if (!string.IsNullOrEmpty(data.PinPai))
            {
                model.PinPai = data.PinPai;
            }
            if (!string.IsNullOrEmpty(data.ChangjiaXinghao))
            {
                model.ChangjiaXinghao = data.ChangjiaXinghao;
            }
            if (!string.IsNullOrEmpty(data.HuoPinLeixing))
            {
                model.HuoPinLeixing = data.HuoPinLeixing;
            }

            if (!string.IsNullOrEmpty(data.lianXiRenPhone))
            {
                model.lianXiRenPhone = data.lianXiRenPhone;
            }
            if (!string.IsNullOrEmpty(data.lianXiRenName))
            {
                model.lianXiRenName = data.lianXiRenName;
            }

            return(model);
        }