public static void JSONFavorisesDebug(Favorises fav) { string serializedFav = SerializeFavorises(fav); Console.WriteLine(serializedFav); Favorises jsonFavorises = DeSerializeFavorises(serializedFav); Console.WriteLine(jsonFavorises.ToString()); }
public int AddFavorises(Favorises favorisesToInsert) { string sql = "INSERT INTO favorises(accountid, recipeid) VALUES (@accountid, @recipeid)"; NpgsqlCommand command = new NpgsqlCommand(sql, conn); command.Parameters.AddWithValue("@accountid", favorisesToInsert.GetOrSetAccountId); command.Parameters.AddWithValue("@recipeid", favorisesToInsert.GetOrSetRecipeId); return(NonQuery(command, "favorises")); }
public void AddFavorises(Favorises fav) { DBController dbc = new DBController(); try { dbc.AddFavorises(fav); } catch (NpgsqlException e) { Console.WriteLine((Program.sqlDebugMessages) ? "AddFavorises: " + e.BaseMessage.ToString() : ""); WebOperationContext ctx = WebOperationContext.Current; ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Conflict; ctx.OutgoingResponse.StatusDescription = e.BaseMessage; } finally { dbc.Close(); } }
public List <Favorises> GetAllFavorises() { string sql = String.Format("SELECT * FROM favorises"); DataRowCollection res = Query(sql); List <Favorises> allFavorises = new List <Favorises>(); if (res.Count >= 1) { foreach (DataRow datarow in res) { Favorises favorises = new Favorises(datarow); allFavorises.Add(favorises); } return(allFavorises); } else { return(allFavorises); } }
public static Favorises GetTestFavorises() { Favorises fav = new Favorises(1, 1); return(fav); }
public static Favorises DeSerializeFavorises(string fav) { Favorises deserializedFav = JSONHelper.Deserialize <Favorises>(fav); return(deserializedFav); }
// // Relationships // //Favorises public static string SerializeFavorises(Favorises fav) { string serializedFav = JSONHelper.Serialize <Favorises>(fav); return(serializedFav); }