示例#1
0
        public HuoPingCaiGou UpdateSingle(int id, HuoPingCaiGouReq data)
        {
            HuoPingCaiGou model = db.HuoPingCaiGou.Find(id);

            SetHuoPingCaiGou(model, data);
            db.SaveChanges();
            return(model);
        }
示例#2
0
        /// <summary>
        /// 设置model,如果不为空就设置,如果为空则和之前一样
        /// </summary>
        /// <param name="target"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public HuoPingCaiGou SetHuoPingCaiGou(HuoPingCaiGou model, HuoPingCaiGouReq data)
        {
            if (data.HPId != null)
            {
                model.HPId = data.HPId.Value;
            }
            if (!string.IsNullOrEmpty(data.HPName))
            {
                model.HPName = data.HPName;
            }
            if (data.SinglePrice != null)
            {
                model.SinglePrice = data.SinglePrice.Value;
            }
            if (!string.IsNullOrEmpty(data.Supplier))
            {
                model.Supplier = data.Supplier;
            }
            if (!string.IsNullOrEmpty(data.ChangjiaXinghao))
            {
                model.ChangjiaXinghao = data.ChangjiaXinghao;
            }
            if (!string.IsNullOrEmpty(data.PinPai))
            {
                model.PinPai = data.PinPai;
            }
            if (!string.IsNullOrEmpty(data.CaiGouDanBianHao))
            {
                model.CaiGouDanBianHao = data.CaiGouDanBianHao;
            }
            if (data.caigouNum != null)
            {
                model.caigouNum = data.caigouNum.Value;
            }
            if (!string.IsNullOrEmpty(data.caigouRen))
            {
                model.caigouRen = data.caigouRen;
            }
            if (data.caigouDate != null && data.caigouDate != DateTime.MinValue && data.caigouDate != SqlDateTime.MinValue.Value)
            {
                model.caigouDate = data.caigouDate.Value;
            }
            if (!string.IsNullOrEmpty(data.shenpiRen))
            {
                model.shenpiRen = data.shenpiRen;
            }
            if (data.shenpiDate != null && data.shenpiDate != DateTime.MinValue && data.shenpiDate != SqlDateTime.MinValue.Value)
            {
                model.shenpiDate = data.shenpiDate.Value;
            }
            if (!string.IsNullOrEmpty(data.caigouState))
            {
                model.caigouState = data.caigouState;
            }
            if (data.rukuId != null)
            {
                model.rukuId = data.rukuId.Value;
            }
            if (data.caigoudanId != null)
            {
                model.caigoudanId = data.caigoudanId.Value;
            }

            return(model);
        }