Ejemplo n.º 1
0
        public static void JSONIngredientInDebug(IngredientIn ing)
        {
            string serializedIngredientIn = SerializeIngredientIn(ing);

            Console.WriteLine(serializedIngredientIn);
            IngredientIn jsonIngredientIn = DeSerializeIngredientIn(serializedIngredientIn);

            Console.WriteLine(jsonIngredientIn.ToString());
        }
Ejemplo n.º 2
0
        public int AddIngredientIn(IngredientIn ingredientInToInsert)
        {
            string sql = "INSERT INTO ingredientin(ingredientid, recipeid, amount) VALUES (@ingredientid, @recipeid, @amount)";

            NpgsqlCommand command = new NpgsqlCommand(sql, conn);

            command.Parameters.AddWithValue("@ingredientid", ingredientInToInsert.GetOrSetIngredientId);
            command.Parameters.AddWithValue("@recipeid", ingredientInToInsert.GetOrSetRecipeId);
            command.Parameters.AddWithValue("@amount", ingredientInToInsert.GetOrSetAmount);

            return(NonQuery(command, "ingredientin"));
        }
Ejemplo n.º 3
0
        public void AddIngredientIn(IngredientIn ing)
        {
            DBController dbc = new DBController();

            try {
                dbc.AddIngredientIn(ing);
            } catch (NpgsqlException e) {
                Console.WriteLine((Program.sqlDebugMessages) ? "AddIngredientIn: " + e.BaseMessage.ToString() : "");
                WebOperationContext ctx = WebOperationContext.Current;
                ctx.OutgoingResponse.StatusCode        = System.Net.HttpStatusCode.Conflict;
                ctx.OutgoingResponse.StatusDescription = e.BaseMessage;
            } finally {
                dbc.Close();
            }
        }
Ejemplo n.º 4
0
        public List <IngredientIn> GetAllIngredientIn()
        {
            string              sql             = String.Format("SELECT * FROM ingredientin");
            DataRowCollection   res             = Query(sql);
            List <IngredientIn> allIngredientIn = new List <IngredientIn>();

            if (res.Count >= 1)
            {
                foreach (DataRow datarow in res)
                {
                    IngredientIn ingredientIn = new IngredientIn(datarow);
                    allIngredientIn.Add(ingredientIn);
                }
                return(allIngredientIn);
            }
            else
            {
                return(allIngredientIn);
            }
        }
Ejemplo n.º 5
0
        public static IngredientIn GetTestIngredientIn()
        {
            IngredientIn ing = new IngredientIn(1, 1, 300);

            return(ing);
        }
Ejemplo n.º 6
0
        public static IngredientIn DeSerializeIngredientIn(string ing)
        {
            IngredientIn deserializedIngredientIn = JSONHelper.Deserialize <IngredientIn>(ing);

            return(deserializedIngredientIn);
        }
Ejemplo n.º 7
0
        //IngredientIn
        public static string SerializeIngredientIn(IngredientIn ing)
        {
            string serializedIngredientIn = JSONHelper.Serialize <IngredientIn>(ing);

            return(serializedIngredientIn);
        }