public JMSJieDianClassObj UpdateSingle(int id, JMSJieDianClassObjReq data) { JMSJieDianClassObj model = db.JMSJieDianClassObj.Find(id); SetJMSJieDianClassObj(model, data); db.SaveChanges(); return(model); }
/// <summary> /// 设置model,如果不为空就设置,如果为空则和之前一样 /// </summary> /// <param name="target"></param> /// <param name="source"></param> /// <returns></returns> public JMSJieDianClassObj SetJMSJieDianClassObj(JMSJieDianClassObj model, JMSJieDianClassObjReq data) { if (data.JmsID != null) { model.JmsID = data.JmsID.Value; } if (!string.IsNullOrEmpty(data.JmsName)) { model.JmsName = data.JmsName; } if (data.JdClassModelID != null) { model.JdClassModelID = data.JdClassModelID.Value; } if (!string.IsNullOrEmpty(data.JdClassModelName)) { model.JdClassModelName = data.JdClassModelName; } if (data.JdClassPaiXu != null) { model.JdClassPaiXu = data.JdClassPaiXu.Value; } if (data.JdClassStateID != null) { model.JdClassStateID = data.JdClassStateID.Value; } if (data.JdClassConfirmID != null) { model.JdClassConfirmID = data.JdClassConfirmID.Value; } if (data.projectid != null) { model.ProjectID = data.projectid.Value; } if (!string.IsNullOrEmpty(data.optName)) { model.optName = data.optName; } if (data.optDateTime != null && data.optDateTime != DateTime.MinValue && data.optDateTime != SqlDateTime.MinValue.Value) { model.optDateTime = data.optDateTime.Value; } if (!string.IsNullOrEmpty(data.JdSpecialState)) { model.JdSpecialState = data.JdSpecialState; } if (!string.IsNullOrEmpty(data.JdSpecialOptName)) { model.JdSpecialOptName = data.JdSpecialOptName; } return(model); }
public static JMSJieDianClassObj TranferModelToObj(JMSJieDianClassModel model, int jmsId, string jmsName, int projectId) { JMSJieDianClassObj obj = new JMSJieDianClassObj(); obj.JdClassModelName = model.JdClassName; obj.JdClassModelID = model.id; obj.JdClassPaiXu = model.JdClassPaiXu; obj.JmsID = jmsId; obj.JmsName = jmsName; obj.ProjectID = projectId; return(obj); }