Beispiel #1
0
        /// <summary>
        /// 设置model,如果不为空就设置,如果为空则和之前一样
        /// </summary>
        /// <param name="target"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public KeRenPeiCan SetKeRenPeiCan(KeRenPeiCan model, KeRenPeiCanReq data)
        {
            if (!string.IsNullOrEmpty(data.CaiPuIds))
            {
                model.CaiPuIds = data.CaiPuIds;
            }
            if (data.DietSpecialId != null)
            {
                model.DietSpecialId = data.DietSpecialId.Value;
            }
            if (!string.IsNullOrEmpty(data.LunchSpecial))
            {
                model.LunchSpecial = data.LunchSpecial;
            }
            if (!string.IsNullOrEmpty(data.SupperSpecial))
            {
                model.SupperSpecial = data.SupperSpecial;
            }
            if (data.CreateDate != null && data.CreateDate != DateTime.MinValue && data.CreateDate != SqlDateTime.MinValue.Value)
            {
                model.CreateDate = data.CreateDate.Value;
            }
            if (!string.IsNullOrEmpty(data.OptName))
            {
                model.OptName = data.OptName;
            }
            if (data.OptId != null)
            {
                model.OptId = data.OptId.Value;
            }

            return(model);
        }
Beispiel #2
0
        public KeRenPeiCan UpdateSingle(int id, KeRenPeiCanReq data)
        {
            KeRenPeiCan model = db.KeRenPeiCan.Find(id);

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