public JMSJieDianObj UpdateSingle(int id, JMSJieDianObjReq data) { JMSJieDianObj model = db.JMSJieDianObj.Find(id); SetJMSJieDianObj(model, data); db.SaveChanges(); return(model); }
public static JMSJieDianObj TranferModelToObj(JMSJieDianModel model, int jmsId, string jmsName, int projectId) { JMSJieDianObj obj = new JMSJieDianObj(); obj.JdModelName = model.JdName; obj.JdClassModelID = model.JdClassID; //obj.JdClassModelName=model. obj.JdModelID = model.id; obj.JdPaiXu = model.JdPaiXu; obj.JmsID = jmsId; obj.JmsName = jmsName; obj.ProjectID = projectId; obj.JmsUploadFileState = model.JmsUploadFileState; using (Context db = new Context()) { obj.JdClassModelName = db.JMSJieDianClassModel.Find(model.JdClassID).JdClassName; } return(obj); }
/// <summary> /// 设置model,如果不为空就设置,如果为空则和之前一样 /// </summary> /// <param name="target"></param> /// <param name="source"></param> /// <returns></returns> public JMSJieDianObj SetJMSJieDianObj(JMSJieDianObj model, JMSJieDianObjReq 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.JdModelID != null) { model.JdModelID = data.JdModelID.Value; } if (!string.IsNullOrEmpty(data.JdModelName)) { model.JdModelName = data.JdModelName; } if (data.JdPaiXu != null) { model.JdPaiXu = data.JdPaiXu.Value; } if (data.JdStateID != null) { model.JdStateID = data.JdStateID.Value; } if (data.jmsJDConfirmID != null) { model.jmsJDConfirmID = data.jmsJDConfirmID.Value; } if (data.xxJDConfirmID != null) { model.xxJDConfirmID = data.xxJDConfirmID.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.JmsUploadFileState)) { model.JmsUploadFileState = data.JmsUploadFileState; } if (!string.IsNullOrEmpty(data.JmsFinishState)) { model.JmsFinishState = data.JmsFinishState; } if (!string.IsNullOrEmpty(data.JdSpecialState)) { model.JdSpecialState = data.JdSpecialState; } if (!string.IsNullOrEmpty(data.JdSpecialOptName)) { model.JdSpecialOptName = data.JdSpecialOptName; } if (data.LastGenzhongDate != null && data.LastGenzhongDate != DateTime.MinValue && data.LastGenzhongDate != SqlDateTime.MinValue.Value) { model.LastGenzhongDate = data.LastGenzhongDate.Value; } return(model); }