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

            SetPaiBanType(model, data);
            db.SaveChanges();
            return(model);
        }
示例#2
0
        /// <summary>
        /// 设置model,如果不为空就设置,如果为空则和之前一样
        /// </summary>
        /// <param name="target"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public PaiBanType SetPaiBanType(PaiBanType model, PaiBanTypeReq data)
        {
            if (!string.IsNullOrEmpty(data.Name))
            {
                model.Name = data.Name;
            }
            if (data.Hours != null)
            {
                model.Hours = data.Hours.Value;
            }
            if (data.OptId != null)
            {
                model.OptId = data.OptId.Value;
            }
            if (!string.IsNullOrEmpty(data.OptName))
            {
                model.OptName = data.OptName;
            }
            if (data.projectid != null)
            {
                model.projectid = data.projectid.Value;
            }
            if (!string.IsNullOrEmpty(data.ProjectName))
            {
                model.ProjectName = data.ProjectName;
            }
            if (data.FromHour != null)
            {
                model.FromHour = data.FromHour.Value;
            }
            if (data.ToHour != null)
            {
                model.ToHour = data.ToHour.Value;
            }
            if (!string.IsNullOrEmpty(data.ValidState))
            {
                model.ValidState = data.ValidState;
            }

            return(model);
        }