示例#1
0
        protected void btnReply_Click(object sender, EventArgs e)
        {
            ThreadReply threadReply = new ThreadReply();
            Users       user        = (Users)Session["user"];
            int         user_id     = user.id;
            string      user_name   = user.name;

            if (String.IsNullOrEmpty(tbReplyContent.Text))
            {
                LblMsg.Text      = "Please write something in the reply! <br/>";
                LblMsg.ForeColor = Color.Red;
            }
            else
            {
                DateTime now = DateTime.Now;
                HFDate.Value = now.ToString("g");
                DateTime mDate = Convert.ToDateTime(HFDate.Value);

                threadReply = new ThreadReply(Convert.ToInt32(HFthreadId.Value), HFDate.Value, tbReplyContent.Text, user_id, user_name);
                int result = threadReply.ReplyThread();
                if (result == 1)
                {
                    Response.Redirect("forumPostEvent.aspx?threadid=" + HFthreadId.Value);
                }
            }
        }
示例#2
0
    private void SaveReply()
    {
        bool              isSuccess = false;
        string            username  = Request.Cookies["Speedo"]["UserName"];
        int               threadID  = Request.QueryString["threadid"].ToInt();
        ThreadDataContext sdc       = new ThreadDataContext();

        try
        {
            ThreadReply tr = new ThreadReply
            {
                ThreadID      = threadID,
                Username      = username,
                ReplyContents = ckeReply.Text,
                DateReply     = DateTime.Now
            };

            sdc.ThreadReplies.InsertOnSubmit(tr);
            sdc.SubmitChanges();
            isSuccess = true;
        }
        catch (Exception ex)
        {
            DALPortal.LogError(username, MethodBase.GetCurrentMethod().ReflectedType.ToString(), MethodBase.GetCurrentMethod().Name, ex.Message);
        }
        finally
        {
            sdc.Dispose();
        }

        if (isSuccess)
        {
            Response.Redirect("Thread.aspx?threadid=" + threadID.ToString() + "&page=1");
        }
    }
        public async Task <IActionResult> CreateReply([FromBody] ThreadReply reply)
        {
            _logger.LogDebug("{Action} request starting.", nameof(CreateReply));

            if (reply.ThreadId <= 0)
            {
                return(BadRequest());
            }

            using (var transaction = _forumDbContext.Database.BeginTransaction())
            {
                reply.TimeCreated = DateTime.UtcNow;
                _forumDbContext.ThreadReplies.Add(reply);

                var thread = await _forumDbContext.Threads.SingleOrDefaultAsync(ci => ci.Id == reply.ThreadId);

                thread.RepliesCount++;
                _forumDbContext.Threads.Update(thread);

                await _forumDbContext.SaveChangesAsync();

                transaction.Commit();
                return(Ok(reply));
            }
        }
        public async Task Init(ThreadReply parameter)
        {
            if (WebManager == null)
            {
                LoginUser();
            }

            _replyManager = new ReplyManager(WebManager);

            Selected = parameter;

            if (Selected.IsEdit)
            {
                Title       = "Edit - " + Selected.Thread.Name;
                _forumReply = await _replyManager.GetReplyCookiesForEditAsync(Selected.QuoteId);

                ReplyBox.Text = _forumReply.Quote;
            }
            else if (Selected.QuoteId > 0)
            {
                Title       = "Quote - " + Selected.Thread.Name;
                _forumReply = await _replyManager.GetReplyCookiesAsync(0, Selected.QuoteId);

                ReplyBox.Text = _forumReply.Quote;
            }
            else
            {
                Title       = "Reply - " + Selected.Thread.Name;
                _forumReply = await _replyManager.GetReplyCookiesAsync(Selected.Thread.ThreadId);
            }
        }
示例#5
0
        public List <ThreadReply> getAllThreadRepliesByThreadId(int threadId)
        {
            string        DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
            SqlConnection myConn    = new SqlConnection(DBConnect);

            string         sqlStmt = "Select * from ThreadReplies WHERE threadId = @paraThreadId";
            SqlDataAdapter da      = new SqlDataAdapter(sqlStmt, myConn);

            da.SelectCommand.Parameters.AddWithValue("@paraThreadId", threadId);

            DataSet ds = new DataSet();

            da.Fill(ds);


            List <ThreadReply> threadReplies = new List <ThreadReply>();
            int rec_cnt = ds.Tables[0].Rows.Count;

            for (int i = 0; i < rec_cnt; i++)
            {
                DataRow row         = ds.Tables[0].Rows[i]; // Sql command returns only one record
                int     Id          = int.Parse(row["Id"].ToString());
                int     tId         = int.Parse(row["threadId"].ToString());
                string  postDate    = row["postDate"].ToString();
                string  postContent = row["postContent"].ToString();
                int     user_id     = int.Parse(row["user_id"].ToString());
                string  user_name   = row["user_name"].ToString();

                ThreadReply reply = new ThreadReply(tId, postDate, postContent, user_id, user_name);
                threadReplies.Add(reply);
            }

            return(threadReplies);
        }
示例#6
0
        public ThreadReply getMaxUserReplyIdByThreadId(int threadId)
        {
            string         DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
            SqlConnection  myConn    = new SqlConnection(DBConnect);
            string         sqlStmt   = "SELECT TOP 1 * FROM ThreadReplies WHERE threadId = @paraThreadId ORDER BY Id DESC";
            SqlDataAdapter da        = new SqlDataAdapter(sqlStmt, myConn);

            da.SelectCommand.Parameters.AddWithValue("@paraThreadId", threadId);
            DataSet ds = new DataSet();

            da.Fill(ds);

            ThreadReply threadReply = new ThreadReply();
            int         rec_cnt     = ds.Tables[0].Rows.Count;

            if (rec_cnt == 1)
            {
                DataRow row         = ds.Tables[0].Rows[0]; // Sql command returns only one record
                int     iId         = int.Parse(row["Id"].ToString());
                int     tId         = int.Parse(row["threadId"].ToString());
                string  postDate    = row["postDate"].ToString();
                string  postContent = row["postContent"].ToString();
                int     user_id     = int.Parse(row["user_id"].ToString());
                string  user_name   = row["user_name"].ToString();

                threadReply = new ThreadReply(iId, tId, postDate, postContent, user_id, user_name);
            }
            else
            {
                threadReply = null;
            }

            return(threadReply);
        }
示例#7
0
        public int Insert(ThreadReply threadReply)
        {
            int        result = 0;
            SqlCommand sqlCmd = new SqlCommand();

            string        DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
            SqlConnection myConn    = new SqlConnection(DBConnect);

            string sqlStmt = "INSERT INTO ThreadReplies (threadId, postDate, postContent, user_id, user_name)" +
                             "VALUES (@paraThreadId, @paraPostDate, @paraPostContent, @paraUserId, @paraUserName)";

            sqlCmd = new SqlCommand(sqlStmt, myConn);

            sqlCmd.Parameters.AddWithValue("@paraThreadId", threadReply.ThreadId);
            sqlCmd.Parameters.AddWithValue("@paraPostDate", threadReply.PostDate);
            sqlCmd.Parameters.AddWithValue("@paraPostContent", threadReply.PostContent);
            sqlCmd.Parameters.AddWithValue("@paraUserId", threadReply.UserId);
            sqlCmd.Parameters.AddWithValue("@paraUserName", threadReply.UserName);

            myConn.Open();
            result = sqlCmd.ExecuteNonQuery();

            myConn.Close();

            return(result);
        }
示例#8
0
    protected void btnSaveChanges_Click(object sender, EventArgs e)
    {
        int replyID = Request.QueryString["threadreplyid"].ToInt();

        using (ThreadDataContext tdc = new ThreadDataContext())
        {
            ThreadReply tr = tdc.ThreadReplies.Where(p => p.ThreadReplyID == replyID).SingleOrDefault();
            tr.ReplyContents = ckeContents.Text;
            tdc.SubmitChanges();
        }
        Response.Redirect("Thread.aspx?threadid=" + Request.QueryString["threadid"] + "&page=1");
    }
示例#9
0
        static DataTable GetDataFromDb(List <tReplies> list)
        {
            ThreadReply threadReply = new ThreadReply();
            DataTable   dt          = new DataTable();

            dt.Columns.Add("trId");
            dt.Columns.Add("tId");
            dt.Columns.Add("postTitle");
            dt.Columns.Add("postDate");
            dt.Columns.Add("postContent");
            dt.Columns.Add("user_id");
            dt.Columns.Add("user_name");
            dt.Columns.Add("userDesc");
            dt.Columns.Add("userDP");
            dt.Columns.Add("userJoinedDate");
            dt.Columns.Add("userThreadCount");
            dt.Columns.Add("orgTag");

            foreach (var TReply in list)
            {
                var row = dt.NewRow();

                row["trId"]            = TReply.trId;
                row["tId"]             = TReply.tId;
                row["postTitle"]       = TReply.postTitle;
                row["postDate"]        = TReply.postDate;
                row["postContent"]     = TReply.postContent;
                row["user_id"]         = TReply.user_id;
                row["user_name"]       = TReply.user_name;
                row["userDesc"]        = TReply.userDesc;
                row["userDP"]          = TReply.userDP;
                row["userJoinedDate"]  = TReply.userJoinedDate;
                row["userThreadCount"] = TReply.userThreadCount;
                row["orgTag"]          = TReply.orgTag;

                dt.Rows.Add(row);
            }

            return(dt);
        }