/// <summary> /// 设置model,如果不为空就设置,如果为空则和之前一样 /// </summary> /// <param name="target"></param> /// <param name="source"></param> /// <returns></returns> public JieDianGengZong SetJieDianGengZong(JieDianGengZong model, JieDianGengZongReq data) { if (data.jdid != null) { model.jdid = data.jdid.Value; } if (!string.IsNullOrEmpty(data.jdName)) { model.jdName = data.jdName; } if (!string.IsNullOrEmpty(data.OptName)) { model.OptName = data.OptName; } if (data.OptId != null) { model.OptId = data.OptId.Value; } if (data.OptDateTime != null && data.OptDateTime != DateTime.MinValue && data.OptDateTime != SqlDateTime.MinValue.Value) { model.OptDateTime = data.OptDateTime.Value; } if (!string.IsNullOrEmpty(data.Desc)) { model.Desc = data.Desc; } if (!string.IsNullOrEmpty(data.State)) { model.State = data.State; } return(model); }
public JieDianGengZong UpdateSingle(int id, JieDianGengZongReq data) { JieDianGengZong model = db.JieDianGengZong.Find(id); SetJieDianGengZong(model, data); db.SaveChanges(); return(model); }