public static bool SetSource(Source oSource) { var oBuilder = new StringBuilder(); oBuilder.AppendLine("REPLACE INTO Sources "); oBuilder.AppendLine("(SourceId, Name,NewsLink)"); oBuilder.AppendLine("VALUES"); oBuilder.AppendLine( $"({oSource.SourceId},{oSource.Name},{oSource.NewsLink})"); if (connection != null) { var oCmd = new SQLiteCommand(oBuilder.ToString(), connection); return oCmd.ExecuteNonQuery() == 1; } return false; }
public static List<Source> GetAllSources() { var lResult = new List<Source>(); var oBuilder = new StringBuilder(); oBuilder.AppendLine("SELECT "); oBuilder.AppendLine("SourceId, Name, NewsLink "); oBuilder.AppendLine("FROM "); oBuilder.AppendLine("Sources"); if (connection != null) { var oCmd = new SQLiteCommand(oBuilder.ToString(), connection); using (var oReader = oCmd.ExecuteReader()) { while (oReader.Read()) { var oSource = new Source(oReader.GetInt32(oReader.GetOrdinal("SourceId")), oReader["Name"]?.ToString(), oReader["NewsLink"]?.ToString()); lResult.Add(oSource); } } } return lResult; }
public SourceToManga(string link, Source source) { this.Link = link; this.Source = source; }