public JmsFile UpdateSingle(int id, JmsFileReq data) { JmsFile model = db.JmsFile.Find(id); SetJmsFile(model, data); db.SaveChanges(); return(model); }
/// <summary> /// 设置model,如果不为空就设置,如果为空则和之前一样 /// </summary> /// <param name="target"></param> /// <param name="source"></param> /// <returns></returns> public JmsFile SetJmsFile(JmsFile model, JmsFileReq data) { if (data.DirectoryId != null) { model.DirectoryId = data.DirectoryId.Value; } if (!string.IsNullOrEmpty(data.DirectoryName)) { model.DirectoryName = data.DirectoryName; } if (!string.IsNullOrEmpty(data.Name)) { model.Name = data.Name; } if (!string.IsNullOrEmpty(data.State)) { model.State = data.State; } if (!string.IsNullOrEmpty(data.ZhengLiState)) { model.ZhengLiState = data.ZhengLiState; } if (data.OptDateTime != null && data.OptDateTime != DateTime.MinValue && data.OptDateTime != SqlDateTime.MinValue.Value) { model.OptDateTime = data.OptDateTime.Value; } if (!string.IsNullOrEmpty(data.OptName)) { model.OptName = data.OptName; } if (data.OptId != null) { model.OptId = data.OptId.Value; } if (data.JmsId != null) { model.JmsId = data.JmsId.Value; } if (!string.IsNullOrEmpty(data.JmsName)) { model.JmsName = data.JmsName; } if (!string.IsNullOrEmpty(data.FileAbsolutePath)) { model.FileAbsolutePath = data.FileAbsolutePath; } if (!string.IsNullOrEmpty(data.FileRelatePath)) { model.FileRelatePath = data.FileRelatePath; } if (!string.IsNullOrEmpty(data.Type)) { model.Type = data.Type; } return(model); }