Exemplo n.º 1
0
        public List <Review> GetAllReviewsByUserID(int id)
        {
            string Query = "SELECT TOP(10) [Reviews].ID, [Reviews].Body, [Reviews].Rating, [Reviews].DatePosted, [Users].ID, [Users].Name, [Books].ID, [Books].Title " +
                           "FROM ([Reviews] " +
                           "INNER JOIN [Books] ON [Books].ID = [Reviews].BookID " +
                           "INNER JOIN [Users] ON [Users].ID = [Reviews].UserID) " +
                           "WHERE [Users].ID = @userid " +
                           "ORDER BY [Reviews].DatePosted DESC";

            List <KeyValuePair <string, string> > Params = new List <KeyValuePair <string, string> >();

            Params.Add(new KeyValuePair <string, string>("userid", id.ToString()));
            DataSet Results = this.ExecuteSQL(Query, Params);

            List <Review> Reviews = new List <Review>();

            if (Results != null)
            {
                for (int i = 0; i < Results.Tables[0].Rows.Count; i++)
                {
                    Review r = DataSetParser.DataSetToReview(Results, i);
                    Reviews.Add(r);
                }
            }
            return(Reviews);
        }
Exemplo n.º 2
0
        public Review GetReviewByID(int id)
        {
            string Query = "SELECT [Reviews].ID, [Reviews].Body, [Reviews].Rating, [Reviews].DatePosted," +
                           "[Users].ID, [Users].Name, [Books].ID, [Books].Title " +
                           "FROM ([Reviews] INNER JOIN [Users] ON [Reviews].UserID = [Users].ID " +
                           "INNER JOIN [Books] ON [Books].ID = [Reviews].BookID) " +
                           "WHERE [Reviews].ID = @reviewId";
            List <KeyValuePair <string, string> > Params = new List <KeyValuePair <string, string> >();

            Params.Add(new KeyValuePair <string, string>("reviewId", id.ToString()));
            DataSet Result = this.ExecuteSQL(Query, Params);
            Review  R      = null;

            if (Result != null)
            {
                R = DataSetParser.DataSetToReview(Result, 0);
            }
            return(R);
        }
Exemplo n.º 3
0
        public List <Review> GetAllReviews()
        {
            string Query = "SELECT [Reviews].ID, [Reviews].Body, [Reviews].Rating, [Reviews].DatePosted, " +
                           "[Books].ID, [Books].Title, [Users].Name FROM " +
                           "([Reviews] INNER JOIN[Books] ON[Books].ID = [Reviews].BookID " +
                           "INNER JOIN[Authors] ON[Authors].ID = [Books].AuthorID " +
                           "INNER JOIN[Users] ON [Users].ID = [Reviews].UserID) " +
                           "ORDER BY[Reviews].DatePosted DESC";

            List <KeyValuePair <string, string> > Params = new List <KeyValuePair <string, string> >();
            DataSet Results = this.ExecuteSQL(Query, Params);

            List <Review> Reviews = new List <Review>();

            if (Results != null)
            {
                for (int i = 0; i < Results.Tables[0].Rows.Count; i++)
                {
                    Review r = DataSetParser.DataSetToReview(Results, i);
                    Reviews.Add(r);
                }
            }
            return(Reviews);
        }