예제 #1
0
        public JMSShouKuan UpdateSingle(int id, JMSShouKuanReq data)
        {
            JMSShouKuan model = db.JMSShouKuan.Find(id);

            SetJMSShouKuan(model, data);
            db.SaveChanges();
            return(model);
        }
예제 #2
0
        /// <summary>
        /// 设置model,如果不为空就设置,如果为空则和之前一样
        /// </summary>
        /// <param name="target"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public JMSShouKuan SetJMSShouKuan(JMSShouKuan model, JMSShouKuanReq data)
        {
            if (data.JmsShouKuanRuleId != null)
            {
                model.JmsShouKuanRuleId = data.JmsShouKuanRuleId.Value;
            }
            if (!string.IsNullOrEmpty(data.ShouKuanType))
            {
                model.ShouKuanType = data.ShouKuanType;
            }
            if (data.ShouKuanMoney != null)
            {
                model.ShouKuanMoney = data.ShouKuanMoney.Value;
            }
            if (data.ShouKuanTime != null && data.ShouKuanTime != DateTime.MinValue &&
                data.ShouKuanTime != SqlDateTime.MinValue.Value)
            {
                model.ShouKuanTime = data.ShouKuanTime.Value;
            }
            if (!string.IsNullOrEmpty(data.ShouKuanState))
            {
                model.ShouKuanState = data.ShouKuanState;
            }
            if (data.ShouKuanConfirmerId != null)
            {
                model.ShouKuanConfirmerId = data.ShouKuanConfirmerId.Value;
            }
            if (!string.IsNullOrEmpty(data.ShouKuanConfirmerName))
            {
                model.ShouKuanConfirmerName = data.ShouKuanConfirmerName;
            }
            if (data.ShouKuanConfirmDate != null && data.ShouKuanConfirmDate != DateTime.MinValue &&
                data.ShouKuanConfirmDate != SqlDateTime.MinValue.Value)
            {
                model.ShouKuanConfirmDate = data.ShouKuanConfirmDate.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;
            }

            return(model);
        }