public static void SetEnabled(Recipe recipe) { using (DAC dac = new DAC()) { string statement = string.Format("UPDATE Recipe SET IsEnabled = {0} WHERE Name = '{1}';", recipe.IsEnabled ? 1 : 0, recipe.Name); dac.ExecuteCommand(statement); } }
public static void Update(Position pos) { using (DAC dac = new DAC()) { string statement = string.Format("UPDATE Location SET Latitude = {0}, Longitude = {1}, FetchedOn = '{2}' WHERE Key = '{3}';", pos.Latitude, pos.Longitude, pos.FetchedOn, pos.Key); dac.ExecuteCommand(statement); } }
public static void Clear() { using (DAC dac = new DAC()) { string statement = string.Format("DELETE FROM News;"); dac.ExecuteCommand(statement); } }
public static void Insert(LocationEntry entry) { using (DAC dac = new DAC()) { string statement = string.Format("INSERT INTO LocationHistory (Latitude, Longitude, VisitedOn, IsKnown, KnownKey) VALUES ({0}, {1}, '{2}', {3}, '{4}');", entry.Latitude, entry.Longitude, entry.VisitedOn, entry.IsKnown ? 1 : 0, entry.KnownKey); dac.ExecuteCommand(statement); } }
public static void Insert(WeatherEntry entry) { using (DAC dac = new DAC()) { string statement = string.Format("INSERT INTO WeatherHistory (Latitude, Longitude, Temperature, Forecast, FetchedOn) VALUES ({0}, {1}, {2}, '{3}', '{4}');", entry.Latitude, entry.Longitude, entry.Temperature, entry.Forecast, entry.FetchedOn); dac.ExecuteCommand(statement); } }
public static int Set(string key, string value) { value = value.Replace("'", "''"); string statement = string.Format("UPDATE Settings SET SettingValue = '{0}', UpdatedOn = '{1}' WHERE [SettingKey] = '{2}';", value, DateTime.Now.ToString(), key); using (DAC dac = new DAC()) { return(dac.ExecuteCommand(statement)); } }
public static bool IsDuplicate(NewsEntry entry) { using (DAC dac = new DAC()) { string query = string.Format("SELECT Title FROM News WHERE Provider = '{0}' AND Title = '{1}' AND EmailId = '{2}';", entry.Provider, entry.Title, entry.EmailId); using (DbDataReader reader = dac.FetchRecords(query)) { return(reader.HasRows); } } }
public static void Insert(NewsEntry entry) { entry.Title = entry.Title.Replace("'", "''"); entry.Summary = entry.Summary.Replace("'", "''"); using (DAC dac = new DAC()) { string statement = string.Format("INSERT INTO News (Provider, Title, Url, EmailId, EmailSent) VALUES ('{0}', '{1}', '{2}', '{3}', {4});", entry.Provider, entry.Title, entry.Url, entry.EmailId, entry.EmailSent ? 1 : 0); dac.ExecuteCommand(statement); } }
public static string Get(string key) { try { string statement = string.Format("SELECT SettingValue FROM Settings WHERE SettingKey = '{0}';", key); using (DAC dac = new DAC()) { return(dac.ExecuteScalar(statement).ToString()); } } catch (Exception exception) { return(exception.Message); } }
public static List <Recipe> FetchByGroupUid(long groupUid) { List <Recipe> recipeList = new List <Recipe>(); using (DAC dac = new DAC()) { using (DbDataReader reader = dac.FetchRecords("SELECT * FROM Recipe WHERE GroupUID = " + groupUid + ";")) { while (reader.Read()) { recipeList.Add(Fetch(reader)); } } } return(recipeList); }
public static List <Position> FetchAll() { List <Position> all = new List <Position>(); using (DAC dac = new DAC()) { using (DbDataReader reader = dac.FetchRecords("SELECT * FROM Location;")) { while (reader.Read()) { all.Add(Fetch(reader)); } } } return(all); }
public static List <RecipeGroup> FetchAll() { List <RecipeGroup> all = new List <RecipeGroup>(); using (DAC dac = new DAC()) { using (DbDataReader reader = dac.FetchRecords("SELECT * FROM RecipeGroup ORDER BY UID;")) { while (reader.Read()) { all.Add(Fetch(reader)); } } } return(all); }
public static RecipeGroup FetchByUid(int uid) { RecipeGroup group = null; using (DAC dac = new DAC()) { using (DbDataReader reader = dac.FetchRecords("SELECT * FROM RecipeGrou] WHERE UID = " + uid + ";")) { if (reader.Read()) { group = Fetch(reader); } } } return(group); }
public static List <NewsEntry> FetchAll() { List <NewsEntry> all = new List <NewsEntry>(); using (DAC dac = new DAC()) { using (DbDataReader reader = dac.FetchRecords("SELECT * FROM News;")) { while (reader.Read()) { all.Add(Fetch(reader)); } } } return(all); }