public void LoadDataPost(BoardPost boardPost, List<BoardPost> list, BoardForum forum, Group group) { ViewPostUC.Thread = boardPost; ViewPostUC.Posts = list; ViewPostUC.forum = forum; ViewPostUC.group = group; pnlForum.Controls.Add(ViewPostUC); }
protected void btnSubmit_Click(object sender, EventArgs e) { BoardPost post = new BoardPost(); post.Name = txtName.Text; post.PageName = txtName.Text; // post.Post = txtPost.Text; post.Post = Editor1.Content; _presenter.Save(post); }
public void SetData(BoardForum forum, BoardPost thread) { UcForumHeader.LoadForum(forum); if (thread != null) { lblName.Text = "Trả lời bài viết " + thread.Name + " !"; txtName.Text = "Re: " + thread.Name; } else lblName.Text = "Đăng bài mới"; }
public void DeletePost(BoardPost boardPost) { using (SPKTDataContext dc = _conn.GetContext()) { dc.BoardPosts.Attach(boardPost, true); //if this is a thread then we need to delete all of it's children if (boardPost.IsThread) dc.BoardPosts.DeleteAllOnSubmit(dc.BoardPosts.Where(bp => bp.ThreadID == boardPost.PostID)); dc.BoardPosts.DeleteOnSubmit(boardPost); dc.SubmitChanges(); } }
public void LoadData(BoardPost Thread, List<BoardPost> Posts) { UCViewpost.lkUsername.Text = Thread.Username; UCViewpost.lkUsername.NavigateUrl = "../" + Thread.Username; UCViewpost.lblCreDate.Text = Thread.UpdateDate.ToShortDateString(); UCViewpost.lblUpdate.Text = Thread.CreateDate.ToShortDateString(); UCViewpost.lblTilte.Text = Thread.Name; UCViewpost.lblDescript.Text = Thread.Post; UCViewpost.ImgAvatar.ImageUrl = "/Image/ProfileAvatar.aspx?AccountID=" + Thread.AccountID.ToString(); UCViewpost.lkReply.Text = "Reply"; UCViewpost.lkReply.NavigateUrl = "/Forums/Post.aspx?PostID=" + Thread.PostID.ToString(); UCViewpost.repPost.DataSource = Posts; UCViewpost.repPost.DataBind(); }
public void LoadData(BoardPost Thread, List<BoardPost> Posts) { linkUsername.Text = Thread.Username; linkUsername.NavigateUrl = "../" + Thread.Username; lblUpdateDate.Text = Thread.UpdateDate.ToShortDateString(); lblCreateDate.Text = Thread.CreateDate.ToShortDateString(); lblSubject.Text = Thread.Name; //lblDescription.Text = Thread.Post.Filter(); lblSubject.Text = Thread.Name; lblDescription.Text = Thread.Post; imgProfile.ImageUrl = "/Image/ProfileAvatar.aspx?AccountID=" + Thread.AccountID.ToString(); linkReply.Text = "Reply"; linkReply.NavigateUrl = "/Forums/Post.aspx?PostID=" + Thread.PostID.ToString(); repPosts.DataSource = Posts; repPosts.DataBind(); }
public void LoadData(BoardPost Thread, List<BoardPost> Posts, BoardForum forum, Group group) { linkUsername.Text = Thread.Username; linkUsername.NavigateUrl = "../" + Thread.Username; lblUpdateDate.Text = Thread.UpdateDate.ToShortDateString(); lblCreateDate.Text = Thread.CreateDate.ToShortDateString(); lblSubject.Text = Thread.Name; //lblDescription.Text = Thread.Post.Filter(); lblSubject.Text = Thread.Name; lblDescription.Text = Thread.Post; imgProfile.ImageUrl = "/Image/ProfileAvatar.aspx?AccountID=" + Thread.AccountID.ToString(); linkReply.Text = "Bình Luận"; //linkReply.NavigateUrl = "/Forums/Post.aspx?PostID=" + Thread.PostID.ToString(); linkReply.NavigateUrl = "/Groups/PostGroupforum.aspx?PostID=" + Thread.PostID.ToString() + "&IsThread=" + false + "&ForumID=" + forum.ForumID + "&GroupID=" + group.GroupID; repPosts.DataSource = Posts; repPosts.DataBind(); }
public void AddNewBoardPostAlert(BoardCategory category, BoardForum forum, BoardPost post, BoardPost thread, Group group) { Init(); alert.AlertTypeID = (int)AlertType.AlertTypes.NewBoardPost; alertMessage = "<div class=\"AlertHeader\">" + GetProfileImage(_userSession.CurrentUser.AccountID) + GetProfileUrl(_userSession.CurrentUser.UserName) + " has just added a new post: <b>" + post.Name + "</b></div>"; /*alertMessage += "<div class=\"AlertRow\"><a href=\"" + _webContext.RootUrl + "forums/" + category.PageName + "/" + forum.PageName + "/" + thread.PageName + ".aspx" + "\">" + _webContext.RootUrl + "forums/" + category.PageName + "/" + forum.PageName + "/" + thread.PageName + ".aspx</a></div>";*/ alertMessage += "<div class=\"AlertRow\"><a href=\"" + _webContext.RootUrl + "Groups/ViewGroupForumPost" + ".aspx?PostID=" +post.PostID + "&GroupID=" + group.GroupID +"</a></div>"; alert.Message = alertMessage; SaveAlert(alert); SendAlertToGroup(alert, group); }
public void AddNewBoardThreadAlert(BoardCategory category, BoardForum forum, BoardPost post) { Init(); alert.AlertTypeID = (int)AlertType.AlertTypes.NewBoardThread; alertMessage = "<div class=\"AlertHeader\">" + GetProfileImage(_userSession.CurrentUser.AccountID) + GetProfileUrl(_userSession.CurrentUser.UserName) + " has just added a new thread on the board: <b>" + post.Name + "</b></div>"; alertMessage += "<div class=\"AlertRow\"><a href=\"" + _webContext.RootUrl + "forums/" + category.PageName + "/" + forum.PageName + "/" + post.PageName + ".aspx" + "\">" + _webContext.RootUrl + "forums/" + category.PageName + "/" + forum.PageName + "/" + post.PageName + ".aspx</a></div>"; alert.Message = alertMessage; SaveAlert(alert); SendAlertToFriends(alert); }
public Int64 SavePost(BoardPost boardPost) { using (SPKTDataContext dc = _conn.GetContext()) { if (boardPost.PostID > 0) { dc.BoardPosts.Attach(boardPost, true); } else { //get the parent containers when a new post is created // to update their post counts BoardCategory bc = (from c in dc.BoardCategories join f in dc.BoardForums on c.CategoryID equals f.CategoryID where f.ForumID == boardPost.ForumID select c).FirstOrDefault(); BoardForum bf = (from f in dc.BoardForums where f.ForumID == boardPost.ForumID select f).FirstOrDefault(); //update the thread count if (boardPost.IsThread) { bc.ThreadCount = bc.ThreadCount + 1; bf.ThreadCount = bf.ThreadCount + 1; } //update the post count else { bc.PostCount = bc.PostCount + 1; bf.PostCount = bf.PostCount + 1; //update post count on thread BoardPost bThread = null; if (boardPost.ThreadID != 0) { bThread = (from p in dc.BoardPosts where p.PostID == boardPost.ThreadID select p).FirstOrDefault(); } if (bThread != null) { bThread.ReplyCount = bThread.ReplyCount + 1; } } dc.BoardPosts.InsertOnSubmit(boardPost); } dc.SubmitChanges(); } return boardPost.PostID; }
public void AddNewBoardThreadAlert(BoardCategory category, BoardForum forum, BoardPost post) { Init(); alert.AlertTypeID = (int)AlertType.AlertTypes.NewBoardThread; /*alertMessage = "<div >" + GetProfileImage(_userSession.CurrentUser.AccountID) + GetProfileUrl(_userSession.CurrentUser.UserName) + " vừa mới thêm bài viết mới: <b>" + post.Name + "</b></div>"; alertMessage += "<div ><a href=\"" + _webContext.RootUrl + "forums/" + category.PageName + "/" + forum.PageName + "/" + post.PageName + ".aspx" + "\">" + _webContext.RootUrl + "forums/" + category.PageName + "/" + forum.PageName + "/" + post.PageName + ".aspx</a></div>";*/ alertMessage = "<div >" + GetProfileImage(_userSession.CurrentUser.AccountID) + "<br>" + GetProfileUrl(_userSession.CurrentUser.UserName) + " vừa mới đăng bài viết: "; alertMessage += "<a href=\"" + _webContext.RootUrl + "forums/" + category.PageName + "/" + forum.PageName.ToLower() + "/" + post.PageName.ToLower() + ".aspx" + "\">" + post.Name + "</a></div>"; alert.Message = alertMessage; alert.Message = alertMessage; SaveAlert(alert); //SendAlertToFriends(alert); }
public void AddNewBoardThreadAlert(BoardCategory category, BoardForum forum, BoardPost post, Group group) { //Right Init(); alert.AlertTypeID = (int)AlertType.AlertTypes.NewBoardThread; /*alertMessage = "<div >" + GetProfileImage(_userSession.CurrentUser.AccountID) + GetProfileUrl(_userSession.CurrentUser.UserName) + "vừa mới thêm bài viết mới ở trên: <b>" + post.Name + "</b></div>";*/ /*alertMessage += "<div ><a href=\'" + _webContext.RootUrl + "forums/" + category.PageName + "/" + forum.PageName + "/" + post.PageName + ".aspx" + "\">" + _webContext.RootUrl + "forums/" + category.PageName + "/" + forum.PageName + "/" + post.PageName + ".aspx'>"+post.Name+"</a></div>";*/ alertMessage += "<div >"+ GetProfileImage(_userSession.CurrentUser.AccountID)+"</br>"+ GetProfileUrl(_userSession.CurrentUser.UserName) + "vừa mới thêm bài viết mới <b>"+ "<a href=\"" + _webContext.RootUrl + "Groups/ViewGroupForumPost" + ".aspx?PostID=" + post.PostID + "&GroupID=" + group.GroupID + "\">"+ post.Name + "</a></div>"; alert.Message = alertMessage; SaveAlert(alert); SendAlertToGroup(alert, group); }
public void AddNewBoardPostAlert(BoardCategory category, BoardForum forum, BoardPost post, BoardPost thread) { Init(); alert.AlertTypeID = (int)AlertType.AlertTypes.NewBoardPost; alertMessage = "<div >" + GetProfileImage(_userSession.CurrentUser.AccountID) +"<br>"+ GetProfileUrl(_userSession.CurrentUser.UserName) + " vừa mới trả lời bài viết: "; alertMessage += "<a href=\"" + _webContext.RootUrl + "forums/" + category.PageName.ToLower() + "/" + forum.PageName.ToLower() + "/" + thread.PageName.ToLower() + ".aspx" + "\">"+thread.Name+":"+post.Post.Substring(0,10)+"..."+"</a></div>"; alert.Message = alertMessage; SaveAlert(alert); //SendAlertToFriends(alert); }
public void LoadDataPost(BoardPost boardPost, List<BoardPost> list, BoardForum forum, Group group) { }
public void SetData(BoardForum forum, BoardPost thread) { }
public void Save(BoardPost post) { //is new thread if (_webContext.LoggedIn) { post.ReplyByAccountID = _webContext.AccountID; post.ReplyByUsername = _webContext.CurrentUser.UserName; if (_webContext.PostID > 0) { BoardPost postToReplyToo = _postRepository.GetPostByID(_webContext.PostID); if (postToReplyToo.IsThread) post.ThreadID = postToReplyToo.PostID; else { //if post.ThreadID = postToReplyToo.ThreadID thì ở thread show tất cả bình luận. post.ThreadID = postToReplyToo.PostID; } post.ForumID = postToReplyToo.ForumID; } else if (_webContext.ForumID > 0) { post.ForumID = _webContext.ForumID; post.IsThread = _webContext.IsThread; if (!_postRepository.CheckPostPageNameIsUnique(post.PageName,post.ForumID)) { _view.SetErrorMessage("The page name you are trying to use is already in use!"); return; } } post.CreateDate = DateTime.Now; post.UpdateDate = DateTime.Now; post.AccountID = _webContext.CurrentUser.AccountID; post.Username = _webContext.CurrentUser.UserName; post.ReplyCount = 0; post.ViewCount = 0; if (post.PageName != null) post.PageName = post.PageName.Replace(" ", "-"); else { post.PageName = post.Name; post.PageName = post.PageName.Replace(" ", "-"); } post.PostID = _postRepository.SavePost(post); BoardForum forum = _forumRepository.GetForumByID(post.ForumID); forum.LastPostByAccountID = post.AccountID; forum.LastPostByUsername = post.Username; _forumRepository.SaveForum(forum); BoardCategory category = _categoryRepository.GetCategoryByCategoryID(forum.CategoryID); category.LastPostByAccountID = post.AccountID; category.LastPostByUsername = post.Username; _categoryRepository.SaveCategory(category); BoardPost thread; if (post.IsThread) thread = _postRepository.GetPostByID(post.PostID); else thread = _postRepository.GetPostByID((long)post.ThreadID); //is this forum part of a group? Group group = _groupRepository.GetGroupByForumID(forum.ForumID); //add an alert to the filter if (post.IsThread) { //is this a group forum? if (group != null) _alertService.AddNewBoardThreadAlert(category, forum, thread, group); else _alertService.AddNewBoardThreadAlert(category, forum, thread); } else { //is this a group forum? if (group != null) _alertService.AddNewBoardPostAlert(category, forum, post, thread, group); else _alertService.AddNewBoardPostAlert(category, forum, post, thread); } //_redirector.GoToForumsViewPost(forum.PageName, category.PageName, thread.PageName); if(_webContext.IsThread==false) _redirector.Redirect("~/Groups/ViewGroupForumPost.aspx?PostID="+_webContext.PostID+"&GroupID="+_webContext.GroupID); else _redirector.Redirect("~/Groups/ViewGroup.aspx?GroupID=" + _webContext.GroupID); } else _redirector.GoToAccountLoginPage(); }