예제 #1
0
        /// <summary>
        /// 设置model,如果不为空就设置,如果为空则和之前一样
        /// </summary>
        /// <param name="target"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public KeMu SetKeMu(KeMu model, KeMuReq data)
        {
            if (!string.IsNullOrEmpty(data.Name))
            {
                model.Name = data.Name;
            }
            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 (!string.IsNullOrEmpty(data.ValidState))
            {
                model.ValidState = data.ValidState;
            }

            return(model);
        }
예제 #2
0
        public KeMu UpdateSingle(int id, KeMuReq data)
        {
            KeMu model = db.KeMu.Find(id);

            SetKeMu(model, data);
            db.SaveChanges();
            return(model);
        }