public static HasEaten GetTestHasEaten() { DateTime dt = DateTime.Now; HasEaten has = new HasEaten(1, 1, dt, 4.5m); return(has); }
public static void JSONHasEatenDebug(HasEaten has) { string serializedHasEaten = SerializeHasEaten(has); Console.WriteLine(serializedHasEaten); HasEaten jsonHasEaten = DeSerializeHasEaten(serializedHasEaten); Console.WriteLine(jsonHasEaten.ToString()); }
public int AddHasEaten(HasEaten hasEatenToInsert) { string sql = "INSERT INTO haseaten(accountid, recipeid, eatenat, rating) VALUES (@accountid, @recipeid, @eatenat, @rating)"; NpgsqlCommand command = new NpgsqlCommand(sql, conn); command.Parameters.AddWithValue("@accountid", hasEatenToInsert.GetOrSetAccountId); command.Parameters.AddWithValue("@recipeid", hasEatenToInsert.GetOrSetRecipeId); command.Parameters.AddWithValue("@eatenat", hasEatenToInsert.GetOrSetEatenAt); command.Parameters.AddWithValue("@rating", hasEatenToInsert.GetOrSetRating); return(NonQuery(command, "haseaten")); }
public void AddHasEaten(HasEaten has) { DBController dbc = new DBController(); try { dbc.AddHasEaten(has); } catch (NpgsqlException e) { Console.WriteLine((Program.sqlDebugMessages) ? "AddHasEaten: " + e.BaseMessage.ToString() : ""); WebOperationContext ctx = WebOperationContext.Current; ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.Conflict; ctx.OutgoingResponse.StatusDescription = e.BaseMessage; } finally { dbc.Close(); } }
public List <HasEaten> GetAllHasEaten() { string sql = String.Format("SELECT * FROM haseaten"); DataRowCollection res = Query(sql); List <HasEaten> allHasEaten = new List <HasEaten>(); if (res.Count >= 1) { foreach (DataRow datarow in res) { HasEaten hasEaten = new HasEaten(datarow); allHasEaten.Add(hasEaten); } return(allHasEaten); } else { return(allHasEaten); } }
public static HasEaten DeSerializeHasEaten(string has) { HasEaten deserializedHasEaten = JSONHelper.Deserialize <HasEaten>(has); return(deserializedHasEaten); }
//HasEaten public static string SerializeHasEaten(HasEaten has) { string serializedHasEaten = JSONHelper.Serialize <HasEaten>(has); return(serializedHasEaten); }