Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 public void LoadDisplay(List<BoardPost> Threads,BoardForum forum)
 {
     UCForumHeader.lblForumName.Text += forum.Name;
     UCForumHeader.LoadForum(forum);
     UCViewAllPost.LoadForumPost(Threads, forum);
     UCViewTopPost.LoadTopPostInForum();
     UCViewTopPost1.LoadTopPostInCategory();
 }
Ejemplo n.º 3
0
 public void LoadForum(BoardForum forum, List<BoardPost> threads, BoardCategory category, Group group)
 {
     uc.forum = forum;
     uc.category= category;
     uc.Threads=threads;
     uc.group = group;
        pnlForum.Controls.Add(uc);
 }
Ejemplo n.º 4
0
 public ShowViewPostUCPresenter()
 {
     _categoryRepository = new BoardCategoryRepository();
     _forumRepository = new BoardForumRepository();
     _postRepository = new BoardPostRepository();
     _webContext = new WebContext();
     Posts = new List<BoardPost>();
     forum = new BoardForum();
 }
Ejemplo n.º 5
0
 public void DeleteForum(BoardForum boardForum)
 {
     using (SPKTDataContext dc = _conn.GetContext())
     {
         dc.BoardForums.Attach(boardForum, true);
         dc.BoardForums.DeleteOnSubmit(boardForum);
         dc.SubmitChanges();
     }
 }
Ejemplo n.º 6
0
 public void SaveNewForum(BoardForum forum)
 {
     forum.CreateDate = DateTime.Now;
     forum.LastPostDate = DateTime.Now;
     forum.LastPostByAccountID = 0;
     forum.LastPostByUsername = null;
     forum.PostCount = 0;
     forum.ThreadCount = 0;
     _forumRepository.SaveForum(forum);
 }
Ejemplo n.º 7
0
 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";
 }
Ejemplo n.º 8
0
 internal List<BoardPost> LoadPostsInCate()
 {
     List<BoardPost> posts = new List<BoardPost>();
     List<BoardForum> forums = new List<BoardForum>();
     if (_webContext.ForumID > 0)
         forum = _forumRepository.GetForumByID(_webContext.ForumID);
     BoardCategory category = _categoryRepository.GetCategoryByCategoryID(forum.CategoryID);
     forums = _forumRepository.GetForumsByCategoryID(category.CategoryID);
     foreach (BoardForum bforum in forums)
     {
         List<BoardPost> list = _postRepository.GetThreadsByForumID(bforum.ForumID);
         posts.AddRange(list);
     }
     posts.Sort(new Comparison<BoardPost>((st1, st2) => st2.ViewCount.CompareTo(st1.ViewCount)));
     return posts.GetRange(0, 6);
 }
Ejemplo n.º 9
0
        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();
        }
Ejemplo n.º 10
0
        public void LoadData()
        {
            Group          group    = _groupRepository.GetGroupByID(_webContext.GroupID);
            List <Account> accounts = _groupService.GetAllMemberByGroupID(group.GroupID);

            _view.LoadData(group, accounts);

            if (_webContext.CurrentUser != null)
            {
                _view.ShowRequestMembership(true);
            }
            else
            {
                _view.ShowRequestMembership(false);
            }

            //is this public or private data?
            if (group.IsPublic)
            {
                _view.ShowPrivate(true);
                _view.ShowPublic(true);
            }
            else if (ViewerIsMember())
            {
                _view.ShowPrivate(true);
                _view.ShowPublic(true);
            }
            else
            {
                _view.ShowPrivate(false);
                _view.ShowPublic(true);
            }
            BoardForum       forum    = _boardForumRepository.GetForumByGroupID(group.GroupID);
            BoardCategory    category = _boardCategoryRepository.GetCategoryByPageName("Group Forum");
            List <BoardPost> threads  = _boardPostRepository.GetThreadsByForumID(forum.ForumID);

            //_view.LoadForum(forum,threads,category);
            _view.LoadDataPost(_boardPostRepository.GetPostByID(_webContext.PostID), _boardPostRepository.GetPostsByThreadID(_webContext.PostID), forum, group);
        }
Ejemplo n.º 11
0
        public int SaveGroup(Group group)
        {
            int result = 0;

            if (group.GroupID > 0)
            {
                result = _groupRepository.SaveGroup(group);
            }
            else
            {
                result = _groupRepository.SaveGroup(group);

                BoardForum forum = new BoardForum();
                forum.CategoryID          = 8; //group forums container
                forum.CreateDate          = DateTime.Now;
                forum.LastPostByAccountID = _webContext.CurrentUser.AccountID;
                forum.LastPostByUsername  = _webContext.CurrentUser.UserName;
                forum.LastPostDate        = DateTime.Now;
                forum.Name        = group.Name;
                forum.PageName    = group.PageName;
                forum.PostCount   = 0;
                forum.Subject     = group.Name;
                forum.ThreadCount = 0;
                forum.UpdateDate  = DateTime.Now;
                int ForumID = _forumRepository.SaveForum(forum);

                //create relationship between the group and forum
                GroupForum gf = new GroupForum();
                gf.ForumID    = ForumID;
                gf.GroupID    = group.GroupID;
                gf.CreateDate = DateTime.Now;
                _groupForumRepository.SaveGroupForum(gf);
            }

            return(result);
        }
Ejemplo n.º 12
0
 public void LoadName(BoardForum forum)
 {
 }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
 public AddForumPresenter()
 {
     _categoryService = new BoardService();
     forum            = new BoardForum();
 }
Ejemplo n.º 16
0
        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))
                    {
                        _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();
            }
        }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 18
0
 public AddForumPresenter()
 {
     _categoryService = new BoardService();
     forum = new BoardForum();
 }
Ejemplo n.º 19
0
 public void LoadHeaderData(BoardForum forum)
 {
     linkUsername.Text = forum.Name;
 }
Ejemplo n.º 20
0
        public int SaveGroup(Group group)
        {
            int result = 0;
            if (group.GroupID > 0)
            {
                result = _groupRepository.SaveGroup(group);
            }
            else
            {
                result = _groupRepository.SaveGroup(group);

                BoardForum forum = new BoardForum();
                forum.CategoryID = 8; //group forums container
                forum.CreateDate = DateTime.Now;
                forum.LastPostByAccountID = _webContext.CurrentUser.AccountID;
                forum.LastPostByUsername = _webContext.CurrentUser.UserName;
                forum.LastPostDate = DateTime.Now;
                forum.Name = group.Name;
                forum.PageName = group.PageName;
                forum.PostCount = 0;
                forum.Subject = group.Name;
                forum.ThreadCount = 0;
                forum.UpdateDate = DateTime.Now;
                int ForumID = _forumRepository.SaveForum(forum);

                //create relationship between the group and forum
                GroupForum gf = new GroupForum();
                gf.ForumID = ForumID;
                gf.GroupID = group.GroupID;
                gf.CreateDate = DateTime.Now;
                _groupForumRepository.SaveGroupForum(gf);

                //add Groupleader is member
                GroupMember gm = new GroupMember();
                gm.AccountID = _webContext.CurrentUser.AccountID;
                gm.GroupID = group.GroupID;
                gm.CreateDate = DateTime.Now;
                gm.IsAdmin = true;
                gm.IsApproved = true;
                _groupMemberRepository.SaveGroupMember(gm);

            }

            return result;
        }
Ejemplo n.º 21
0
 public void SetData(BoardForum forum, BoardPost thread)
 {
 }
Ejemplo n.º 22
0
 public void Init(IShowViewPostUC view)
 {
     _view = view;
     if(_webContext.ForumID>0)
         forum=_forumRepository.GetForumByID(_webContext.ForumID);
 }
Ejemplo n.º 23
0
 public void AddNewBoardThreadAlert(BoardCategory category, BoardForum forum, BoardPost post)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 24
0
 public Int32 SaveForum(BoardForum boardForum)
 {
     boardForum.UpdateDate = DateTime.Now;
     using (SPKTDataContext dc = _conn.GetContext())
     {
         if (boardForum.ForumID > 0)
         {
             dc.BoardForums.Attach(boardForum, true);
         }
         else
         {
             dc.BoardForums.InsertOnSubmit(boardForum);
         }
         dc.SubmitChanges();
     }
     return boardForum.ForumID;
 }
Ejemplo n.º 25
0
 public void LoadForumPost(List<BoardPost> Threads, BoardForum forum)
 {
     repViewAllPost.DataSource = Threads;
     repViewAllPost.DataBind();
 }
Ejemplo n.º 26
0
 public void LoadDataPost(BoardPost boardPost, List <BoardPost> list, BoardForum forum, Group group)
 {
 }
Ejemplo n.º 27
0
        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);
        }
Ejemplo n.º 28
0
 public void LoadDataPost(BoardPost boardPost, List<BoardPost> list, BoardForum forum, Group group)
 {
 }
Ejemplo n.º 29
0
        void Application_PostResolveRequestCache(object sender, EventArgs e)
        {
            HttpApplication application = (HttpApplication)sender;
            HttpContext     context     = application.Context;

            string[] extensionsToExclude = { ".axd", ".jpg", ".gif", ".png", ".xml", ".config", ".css", ".js", ".htm", ".html" };
            foreach (string s in extensionsToExclude)
            {
                if (application.Request.PhysicalPath.ToLower().Contains(s))
                {
                    return;
                }
            }

            if (!System.IO.File.Exists(application.Request.PhysicalPath))
            {
                if (application.Request.PhysicalPath.ToLower().Contains("blogs"))
                {
                    string[] arr          = application.Request.PhysicalPath.ToLower().Split('\\');
                    string   blogPageName = arr[arr.Length - 1];
                    string   blogUserName = arr[arr.Length - 2];
                    blogPageName = blogPageName.Replace(".aspx", "");

                    if (blogPageName.ToLower() != "profileimage" && blogUserName.ToLower() != "profileavatar")
                    {
                        if (blogPageName == "default")
                        {
                            return;
                        }

                        Account accountBlog = _accountRepository.GetAccountByUsername(blogUserName);

                        if (accountBlog == null)
                        {
                            return;
                        }

                        Blog blog = _blogRepository.GetBlogByPageName(blogPageName, accountBlog.AccountID);

                        context.RewritePath("~/blogs/ViewPost.aspx?BlogID=" + blog.BlogID.ToString());
                    }
                    else
                    {
                        return;
                    }
                }

                else if (application.Request.PhysicalPath.ToLower().Contains("groups") && _webContext.GroupID == 0)
                {
                    string[] arr           = application.Request.PhysicalPath.ToLower().Split('\\');
                    string   groupPageName = arr[arr.Length - 1];
                    groupPageName = groupPageName.Replace(".aspx", "");
                    Group group = _groupRepository.GetGroupByPageName(groupPageName);
                    context.RewritePath("/groups/viewgroup.aspx?GroupID=" + group.GroupID.ToString());
                }
                else if (application.Request.PhysicalPath.ToLower().Contains("mygroups") && application.Request.PhysicalPath.ToLower().Contains("groups"))
                {
                    context.RewritePath("/groups/mygroups.aspx");
                }

                else if (application.Request.PhysicalPath.ToLower().Contains("forums"))
                {
                    string[] arr              = application.Request.PhysicalPath.ToLower().Split('\\');
                    int      forumsPosition   = 0;
                    int      itemsAfterForums = 0;
                    string   categoryPageName = "";
                    string   forumPageName    = "";
                    string   postPageName     = "";

                    for (int i = 0; i < arr.Length; i++)
                    {
                        if (arr[i].ToLower() == "forums")
                        {
                            forumsPosition = i;
                            break;
                        }
                    }

                    itemsAfterForums = (arr.Length - 1) - forumsPosition;

                    if (itemsAfterForums == 2)
                    {
                        categoryPageName = arr[arr.Length - 2];
                        forumPageName    = arr[arr.Length - 1];
                        forumPageName    = forumPageName.Replace(".aspx", "");
                        BoardForum forum = _forumRepository.GetForumByPageName(forumPageName);
                        context.RewritePath("/forums/ViewForum.aspx?ForumID=" + forum.ForumID.ToString() +
                                            "&CategoryPageName=" + categoryPageName + "&ForumPageName=" + forumPageName, true);
                    }
                    else if (itemsAfterForums == 3)
                    {
                        categoryPageName = arr[arr.Length - 3];
                        forumPageName    = arr[arr.Length - 2];
                        postPageName     = arr[arr.Length - 1];
                        postPageName     = postPageName.Replace(".aspx", "");
                        BoardPost post = _postRepository.GetPostByPageName(postPageName);
                        context.RewritePath("/forums/ViewPost.aspx?PostID=" + post.PostID.ToString(), true);
                    }
                }
                else
                {
                    HttpResponse Response = context.Response;
                    HttpRequest  Request  = context.Request;
                    String       Username = Request.Path.Replace("/", "");
                    //
                    Account account = _accountRepository.GetAccountByUsername(Username);
                    _redirector = new Redirector();
                    if (account != null)
                    {
                        _redirector.Redirect("~/Profiles/UserProfile2.aspx?AccountID=" + account.AccountID.ToString());
                    }
                    else
                    {
                        return;
                    }
                }
            }
        }
Ejemplo n.º 30
0
        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);
        }
Ejemplo n.º 31
0
 public void AddNewBoardPostAlert(BoardCategory category, BoardForum forum, BoardPost post, BoardPost thread, Group group)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 32
0
 public void LoadHeaderData(BoardForum forum)
 {
     UCForumHeader.LoadForum(forum);
 }