예제 #1
0
        public static void JSONFavorisesDebug(Favorises fav)
        {
            string serializedFav = SerializeFavorises(fav);

            Console.WriteLine(serializedFav);
            Favorises jsonFavorises = DeSerializeFavorises(serializedFav);

            Console.WriteLine(jsonFavorises.ToString());
        }
예제 #2
0
        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"));
        }
예제 #3
0
        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();
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        public static Favorises GetTestFavorises()
        {
            Favorises fav = new Favorises(1, 1);

            return(fav);
        }
예제 #6
0
        public static Favorises DeSerializeFavorises(string fav)
        {
            Favorises deserializedFav = JSONHelper.Deserialize <Favorises>(fav);

            return(deserializedFav);
        }
예제 #7
0
        //
        // Relationships
        //

        //Favorises
        public static string SerializeFavorises(Favorises fav)
        {
            string serializedFav = JSONHelper.Serialize <Favorises>(fav);

            return(serializedFav);
        }