public KeHuJieDianClassObj UpdateSingle(int id, KeHuJieDianClassObjReq data) { KeHuJieDianClassObj model = db.KeHuJieDianClassObj.Find(id); SetKeHuJieDianClassObj(model, data); db.SaveChanges(); return(model); }
/// <summary> /// 设置model,如果不为空就设置,如果为空则和之前一样 /// </summary> /// <param name="target"></param> /// <param name="source"></param> /// <returns></returns> public KeHuJieDianClassObj SetKeHuJieDianClassObj(KeHuJieDianClassObj model, KeHuJieDianClassObjReq data) { if (data.KeHuID != null) { model.KeHuID = data.KeHuID.Value; } if (!string.IsNullOrEmpty(data.KeHuName)) { model.KeHuName = data.KeHuName; } 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; } if (data.HeTongId != null) { model.HeTongId = data.HeTongId.Value; } return(model); }
public static KeHuJieDianClassObj TranferModelToObj(KeHuJieDianClassModel model, int projectId) { KeHuJieDianClassObj obj = new KeHuJieDianClassObj(); obj.JdClassModelName = model.JdClassName; obj.JdClassModelID = model.id; obj.JdClassPaiXu = model.JdClassPaiXu; obj.ProjectID = projectId; return(obj); }