Пример #1
0
        public HuoPingCaiGouDan UpdateSingle(int id, HuoPingCaiGouDanReq data)
        {
            HuoPingCaiGouDan model = db.HuoPingCaiGouDan.Find(id);

            SetHuoPingCaiGouDan(model, data);
            db.SaveChanges();
            return(model);
        }
Пример #2
0
        /// <summary>
        /// 设置model,如果不为空就设置,如果为空则和之前一样
        /// </summary>
        /// <param name="target"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public HuoPingCaiGouDan SetHuoPingCaiGouDan(HuoPingCaiGouDan model, HuoPingCaiGouDanReq data)
        {
            if (!string.IsNullOrEmpty(data.CaiGouDanBianHao))
            {
                model.CaiGouDanBianHao = data.CaiGouDanBianHao;
            }
            if (data.HPCount != null)
            {
                model.HPCount = data.HPCount.Value;
            }
            if (data.HPZhongLei != null)
            {
                model.HPZhongLei = data.HPZhongLei.Value;
            }
            if (data.HPZongJia != null)
            {
                model.HPZongJia = data.HPZongJia.Value;
            }
            if (!string.IsNullOrEmpty(data.CaiGouDanState))
            {
                model.CaiGouDanState = data.CaiGouDanState;
            }
            if (data.CaiGouDate != null && data.CaiGouDate != DateTime.MinValue && data.CaiGouDate != SqlDateTime.MinValue.Value)
            {
                model.CaiGouDate = data.CaiGouDate.Value;
            }
            if (!string.IsNullOrEmpty(data.optName))
            {
                model.optName = data.optName;
            }
            if (data.optDateTime != null && data.optDateTime != DateTime.MinValue && data.optDateTime != SqlDateTime.MinValue.Value)
            {
                model.optDateTime = data.optDateTime.Value;
            }

            return(model);
        }