Beispiel #1
0
        public ChildCareMain UpdateSingle(int id, ChildCareMainReq data)
        {
            ChildCareMain model = db.ChildCareMain.Find(id);

            SetChildCareMain(model, data);
            db.SaveChanges();
            return(model);
        }
Beispiel #2
0
        /// <summary>
        /// 设置model,如果不为空就设置,如果为空则和之前一样
        /// </summary>
        /// <param name="target"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public ChildCareMain SetChildCareMain(ChildCareMain model, ChildCareMainReq data)
        {
            if (data.ServerDate != null && data.ServerDate != DateTime.MinValue &&
                data.ServerDate != SqlDateTime.MinValue.Value)
            {
                model.ServerDate = data.ServerDate.Value;
            }
            if (data.Temperature != null)
            {
                model.Temperature = data.Temperature.Value;
            }
            if (data.Weight != null)
            {
                model.Weight = data.Weight.Value;
            }
            if (data.OptId != null)
            {
                model.OptId = data.OptId.Value;
            }
            if (!string.IsNullOrEmpty(data.OptName))
            {
                model.OptName = data.OptName;
            }
            if (!string.IsNullOrEmpty(data.ChildDesc))
            {
                model.ChildDesc = data.ChildDesc;
            }
            if (data.KhId != null)
            {
                model.KhId = data.KhId.Value;
            }
            if (!string.IsNullOrEmpty(data.KhName))
            {
                model.KhName = data.KhName;
            }

            return(model);
        }