Esempio n. 1
0
        public static int GetForumPostVotes(programComponents.forumNeeds.ForumPost post)
        {
            var row = staticSource.SelectOneRow("votes FROM " + MysqlHandler.tblForum +
                                                $" WHERE ID = '{post.id}'");
            int votes = Convert.ToInt32(row[0]);

            return(votes);
        }
Esempio n. 2
0
        static internal bool PushNewForumProblem(programComponents.forumNeeds.ForumPost forumPost)
        {
            string name        = forumPost.name;
            string description = forumPost.description;
            var    subjectId   = forumPost.subjectId;
            //name = string.Format("'{0}'", name);
            //description = string.Format("'{0}'", description);
            string nameHolder = "■name"; //alt 254
            string descHolder = "■desc";
            var    qParams    = MysqlHandler.ConstructQueryParams(new string[] { nameHolder, descHolder },
                                                                  new string[] { name, description });

            return(staticSource.InsertInto(MysqlHandler.tblForum
                                           + "(ownerID, name, subjectID, description) VALUES"
                                           + $"('{CurrentUser.id}', '{nameHolder}', '{subjectId}', '{descHolder}')",
                                           qParams));
        }
Esempio n. 3
0
        public static programComponents.forumNeeds.ForumContent GetForum()
        {
            var rows = staticSource.Select("ID, name, subjectID, description, ownerID, votes FROM " +
                                           MysqlHandler.tblForum);
            var post = new programComponents.forumNeeds.ForumPost[rows.Count];
            int i    = 0;

            foreach (var row in rows)
            {
                long   id          = Convert.ToInt64(row[0]);
                string name        = row[1];
                int    subjectId   = Convert.ToInt32(row[2]);
                string description = row[3];
                int    ownerId     = Convert.ToInt32(row[4]);
                int    votes       = Convert.ToInt32(row[5]);
                var    temp        = new programComponents.forumNeeds.ForumPost(id, subjectId, name,
                                                                                description, ownerId, votes);
                //System.Windows.Forms.MessageBox.Show(temp.ToString() );
                post[i++] = temp;
            }
            var content = new programComponents.forumNeeds.ForumContent(post);

            return(content);
        }
Esempio n. 4
0
 static internal bool UpvoteForumProblem(programComponents.forumNeeds.ForumPost post)
 {
     return(staticSource.InsertInto(MysqlHandler.tblForumVotes +
                                    " (userID, forumID) VALUES "
                                    + $"('{CurrentUser.id}', '{post.id}')"));
 }
Esempio n. 5
0
 public static bool TakeBackUpvoteForForum(programComponents.forumNeeds.ForumPost post)
 {
     return(staticSource.DeleteFrom(MysqlHandler.tblForumVotes +
                                    $" WHERE userID = {CurrentUser.id} AND forumID = {post.id}"));
 }
Esempio n. 6
0
 public static bool SetForumPostVotes(programComponents.forumNeeds.ForumPost post, int intoVotes)
 {
     post.votes = intoVotes;
     return(staticSource.Update(MysqlHandler.tblForum + " SET votes =" +
                                $" '{post.votes}' WHERE ID = '{post.id}'"));
 }