Esempio n. 1
0
        public CaiJinInfo UpdateSingle(int id, CaiJinInfoReq data)
        {
            CaiJinInfo model = db.CaiJinInfo.Find(id);

            SetCaiJinInfo(model, data);
            db.SaveChanges();
            return(model);
        }
Esempio n. 2
0
        /// <summary>
        /// 设置model,如果不为空就设置,如果为空则和之前一样
        /// </summary>
        /// <param name="target"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public CaiJinInfo SetCaiJinInfo(CaiJinInfo model, CaiJinInfoReq data)
        {
            if (data.projectid != null)
            {
                model.projectid = data.projectid.Value;
            }
            if (!string.IsNullOrEmpty(data.ProjectName))
            {
                model.ProjectName = data.ProjectName;
            }
            if (data.caijinMoney != null)
            {
                model.caijinMoney = data.caijinMoney.Value;
            }
            if (data.optId != null)
            {
                model.optId = data.optId.Value;
            }
            if (!string.IsNullOrEmpty(data.optName))
            {
                model.optName = data.optName;
            }
            if (data.createDate != null && data.createDate != DateTime.MinValue && data.createDate != SqlDateTime.MinValue.Value)
            {
                model.createDate = data.createDate.Value;
            }
            if (data.checkId != null)
            {
                model.checkId = data.checkId.Value;
            }
            if (!string.IsNullOrEmpty(data.checkName))
            {
                model.checkName = data.checkName;
            }
            if (data.checkDate != null && data.checkDate != DateTime.MinValue && data.checkDate != SqlDateTime.MinValue.Value)
            {
                model.checkDate = data.checkDate.Value;
            }
            if (data.serverDate != null && data.serverDate != DateTime.MinValue && data.serverDate != SqlDateTime.MinValue.Value)
            {
                model.serverDate = data.serverDate.Value;
            }

            return(model);
        }