public static List <CSMUserReview> GetReviews(Guid CSMItemId)
        {
            List <CSMUserReview> reviews = new List <CSMUserReview>();
            string sql = " SELECT ReviewId, " +
                         " MemberId, " +
                         " CSMItemId, " +
                         " Rating, " +
                         " RatedGradeId, " +
                         " GradeAppropriateness, " +
                         " Created, " +
                         " LastModified, " +
                         " TelligentCommentId, " +
                         " ReviewTitle " +
                         " FROM CSMUserReviews " +
                         " WHERE (CSMItemId = @CSMId)";

            try
            {
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["membership"].ConnectionString))
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand(sql, conn))
                    {
                        cmd.Parameters.AddWithValue("@CSMId", CSMItemId);
                        SqlDataReader reader = cmd.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                CSMUserReview review = new CSMUserReview();
                                review.ReviewId             = reader.GetGuid(0);
                                review.MemberId             = reader.GetGuid(1);
                                review.CSMItemId            = reader.GetGuid(2);
                                review.Rating               = reader.GetInt32(3);
                                review.RatedGradeId         = reader.GetGuid(4);
                                review.GradeAppropriateness = reader.GetInt32(5);
                                review.Created              = reader.GetDateTime(6);
                                review.LastModified         = reader.GetDateTime(7);
                                review.TelligentCommentId   = reader.GetGuid(8);
                                review.ReviewTitle          = reader.GetString(9);
                                review.UserReviewIssues     = GetSkills(review.ReviewId);
                                reviews.Add(review);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(reviews);
        }
 public static List<CSMUserReview> GetReviews(Guid CSMItemId)
 {
     List<CSMUserReview> reviews = new List<CSMUserReview>();
     string sql = " SELECT ReviewId, " +
                         " MemberId, " +
                         " CSMItemId, " +
                         " Rating, " +
                         " RatedGradeId, " +
                         " GradeAppropriateness, " +
                         " Created, " +
                         " LastModified, " +
                         " TelligentCommentId, " +
                         " ReviewTitle " +
                         " FROM CSMUserReviews " +
                         " WHERE (CSMItemId = @CSMId)";
     try
     {
         using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["membership"].ConnectionString))
         {
             conn.Open();
             using (SqlCommand cmd = new SqlCommand(sql, conn))
             {
                 cmd.Parameters.AddWithValue("@CSMId", CSMItemId);
                 SqlDataReader reader = cmd.ExecuteReader();
                 if (reader.HasRows)
                 {
                     while (reader.Read())
                     {
                         CSMUserReview review = new CSMUserReview();
                         review.ReviewId = reader.GetGuid(0);
                         review.MemberId = reader.GetGuid(1);
                         review.CSMItemId = reader.GetGuid(2);
                         review.Rating = reader.GetInt32(3);
                         review.RatedGradeId = reader.GetGuid(4);
                         review.GradeAppropriateness = reader.GetInt32(5);
                         review.Created = reader.GetDateTime(6);
                         review.LastModified = reader.GetDateTime(7);
                         review.TelligentCommentId = reader.GetGuid(8);
                         review.ReviewTitle = reader.GetString(9);
                         review.UserReviewIssues = GetSkills(review.ReviewId); 
                         reviews.Add(review);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return reviews;
 }
        public static bool InsertNewReview(CSMUserReview review)
        {
            bool success = false;
            review.ReviewId = Guid.NewGuid();
            string commentId = CommunityHelper.PostComment(review.BlogId, review.BlogPostId, review.ReviewBody, review.UserScreenName);
            string sql = "INSERT INTO [CSMUserReviews] " +
                       "([ReviewId] " +
                       ",[MemberId] " +
                       ",[CSMItemId] " +
                       ",[Rating] " +
                       ",[RatedGradeId] " +
                       ",[GradeAppropriateness] " +
                       ",[Created] " +
                       ",[LastModified] " +
                       ",[TelligentCommentId] " +
                       ",[ReviewTitle] " +
                       ",[IThinkItIs]) " +
                 "VALUES " +
                       "(@ReviewId, " +
                       "@MemberId, " +
                       "@CSMId, " +
                       "@ReviewRating, " +
                       "@GradeId, " +
                       "@GradeNumber, " +
                       "CURRENT_TIMESTAMP, " +
                       "CURRENT_TIMESTAMP, " +
                       "@CommentId, " +
                       "@ReviewTitle, " +
                       "@IThinkItIs) ";
            try
            {
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["membership"].ConnectionString))
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand(sql, conn))
                    {
                        cmd.Parameters.AddWithValue("@CSMId", review.CSMItemId);
                        cmd.Parameters.AddWithValue("@MemberId", review.MemberId);
                        cmd.Parameters.AddWithValue("@GradeId", review.RatedGradeId);
                        cmd.Parameters.AddWithValue("@ReviewRating", review.Rating);
                        cmd.Parameters.AddWithValue("@CommentId", commentId);
                        cmd.Parameters.AddWithValue("@ReviewId", review.ReviewId);
                        cmd.Parameters.AddWithValue("@ReviewTitle", review.ReviewTitle);
                        cmd.Parameters.AddWithValue("@IThinkItIs", review.IThinkItIs);
                        cmd.Parameters.AddWithValue("@GradeNumber", review.GradeAppropriateness);
                        cmd.ExecuteNonQuery();
                        success = true;
                    }

                    if (success)
                    {
                        InsertAllIssues(review.UserReviewIssues, review.ReviewId);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            success = true;
            return success;
        }
        public static bool InsertNewReview(CSMUserReview review)
        {
            bool success = false;

            review.ReviewId = Guid.NewGuid();
            string commentId = CommunityHelper.PostComment(review.BlogId, review.BlogPostId, review.ReviewBody, review.UserScreenName);
            string sql       = "INSERT INTO [CSMUserReviews] " +
                               "([ReviewId] " +
                               ",[MemberId] " +
                               ",[CSMItemId] " +
                               ",[Rating] " +
                               ",[RatedGradeId] " +
                               ",[GradeAppropriateness] " +
                               ",[Created] " +
                               ",[LastModified] " +
                               ",[TelligentCommentId] " +
                               ",[ReviewTitle] " +
                               ",[IThinkItIs]) " +
                               "VALUES " +
                               "(@ReviewId, " +
                               "@MemberId, " +
                               "@CSMId, " +
                               "@ReviewRating, " +
                               "@GradeId, " +
                               "@GradeNumber, " +
                               "CURRENT_TIMESTAMP, " +
                               "CURRENT_TIMESTAMP, " +
                               "@CommentId, " +
                               "@ReviewTitle, " +
                               "@IThinkItIs) ";

            try
            {
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["membership"].ConnectionString))
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand(sql, conn))
                    {
                        cmd.Parameters.AddWithValue("@CSMId", review.CSMItemId);
                        cmd.Parameters.AddWithValue("@MemberId", review.MemberId);
                        cmd.Parameters.AddWithValue("@GradeId", review.RatedGradeId);
                        cmd.Parameters.AddWithValue("@ReviewRating", review.Rating);
                        cmd.Parameters.AddWithValue("@CommentId", commentId);
                        cmd.Parameters.AddWithValue("@ReviewId", review.ReviewId);
                        cmd.Parameters.AddWithValue("@ReviewTitle", review.ReviewTitle);
                        cmd.Parameters.AddWithValue("@IThinkItIs", review.IThinkItIs);
                        cmd.Parameters.AddWithValue("@GradeNumber", review.GradeAppropriateness);
                        cmd.ExecuteNonQuery();
                        success = true;
                    }

                    if (success)
                    {
                        InsertAllIssues(review.UserReviewIssues, review.ReviewId);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            success = true;
            return(success);
        }