コード例 #1
0
        /// <summary>
        /// Inserts a written review into the database
        /// </summary>
        /// <param name="review">Review written</param>
        private static void SubmitReview(Review review)
        {
            string reviewid  = GenerateId();
            string query     = "select reviewid from review where reviewid = '" + reviewid + "'";
            bool   duplicate = true;

            // Check to see (however unlikely) if our reviewid generated already exists
            while (duplicate)
            {
                if (ExecuteQuery.RunSelectQuery(query).Rows.Count == 0)
                {
                    duplicate = false;
                }
                else
                {
                    reviewid = GenerateId();
                }
            }

            review.Reviewid = reviewid;
            query           = "INSERT INTO review (reviewid, userid, businessid, stars, reviewdate, reviewtext) " +
                              "VALUES (@reviewid, @userid, @businessid, @stars, @reviewdate, @reviewtext)"
                              + "ON CONFLICT (reviewid) DO NOTHING;";
            ExecuteQuery.RunInsert(review, query);
        }
コード例 #2
0
        /// <summary>
        /// Inserts a checkin for a business
        /// </summary>
        /// <param name="businessid">Business id to check into</param>
        private static void CheckIn(Business business)
        {
            string query = "insert into businesscheckins (day, checkintime, businessid, count) " +
                           "values (default, default, @businessid, default)" +
                           "on conflict (day, checkintime, businessid) do update set count = businesscheckins.count + 1";

            ExecuteQuery.RunInsert(business, query);
        }
コード例 #3
0
 public void Execute()
 {
     ExecuteQuery.RunSelectQuery(Query);
 }