public ActionResult List(string parent)
        {
            try
            {
                var forum = new ForumsDetails() { FolderPath = parent.StartWithSlash(), LibraryName = parent };

                var output = CreateList(ForumService.GetForumsList(forum));
                return PartialView("Forums", output);
            }
            catch (Exception ex) { throw ex; }
        }
        public ActionResult GetListofForums(string parent)
        {
            try
            {
                var forumsList = ForumService.GetListofForums(parent);

                var output = ConvertToForumDetailsListModel(forumsList);

                var forum = new ForumsDetailsModel();
                if (null == parent)
                    forum.IsRoot = true;

                forum.SubForums.AddRange(output);

                if (parent == null) return View("SingleForum", forum);

                forum = null;
                var names = parent.ForumSplit();
                foreach (var item in names)
                {
                    forum = (forum == null) ? output.FirstOrDefault(x => x.DisplayName == item) : forum.SubForums.FirstOrDefault(x => x.DisplayName == item);
                }

                if (forum == null) return View("SingleForum", null);

                var postForums = new ForumsDetails() { FolderPath = forum.ForumFullPath.StartWithSlash(), LibraryName = forum.ForumFullPath };

                if (ForumService.IsForumExist(postForums))
                {
                    var topicResult = CreateList(ForumService.GetForumsList(postForums));
                    forum.Topic.AddRange(topicResult);
                    forum.IsSPFolder = true;
                }

                foreach (var subforums in forum.SubForums)
                {
                    var topics = new ForumsDetails() { FolderPath = subforums.ForumFullPath.StartWithSlash(), LibraryName = subforums.ForumFullPath };
                    if (ForumService.IsForumExist(topics))
                        subforums.TopicCount = ForumService.GetTopicCount(subforums.ForumFullPath);
                }

                return View("SingleForum", forum);
            }
            catch (Exception ex) { throw ex; }
        }
        public void CreateTopicForForums(ForumsDetails forumsObj, ForumsDetailsModel toForumsDetailsModel)
        {
            foreach (var forums in forumsObj.Topic)
            {
                var subForumsTopicObj = ConvertToForumDetailsModel(forums);

                if (forums.Topic.Count > 0)
                    CreateSubForums(forums, subForumsTopicObj);

                toForumsDetailsModel.Topic.Add(subForumsTopicObj);
            }
        }
        public void CreateReply(ForumsDetails forumsObj, ForumsDetailsModel toForumsDetailsModel)
        {
            //This is used to fill Subforum model object
            foreach (var forums in forumsObj.SubForums)
            {
                var subForumsObj = ConvertToForumDetailsModel(forums);

                if (forums.SubForums.Count > 0)
                    CreateSubForums(forums, subForumsObj);

                toForumsDetailsModel.SubForums.Add(subForumsObj);
            }

            //This is used to fill Topics model object which is added for forum
            foreach (var forums in forumsObj.Topic)
            {
                var forumTopicObj = ConvertToForumDetailsModel(forums);

                if (forums.Topic.Count > 0)
                    CreateTopicForForums(forums, forumTopicObj);

                toForumsDetailsModel.Topic.Add(forumTopicObj);
            }

            //This is used to fill Reply model object which is added for topic
            foreach (var forums in forumsObj.Children)
            {
                var subReplyObj = ConvertToForumDetailsModel(forums);

                if (forums.Children.Count > 0)
                    CreateReply(forums, subReplyObj);

                toForumsDetailsModel.Children.Add(subReplyObj);
            }
        }
        public ActionResult NewTopicRequest(FormCollection collection)
        {
            try
            {
                SetUserFullName();

                var topicBody = collection.Get("txtareaBody");
                var topicTitle = collection.Get("txtTitle");
                var topicForumPath = collection.Get("txtforumpath");
                string badword;
                string badWordList = ForumSubscriptionService.GetBadWords();
                if (Helper.ContainsBadWords(topicBody, badWordList, out badword))
                    throw new Exception("Your topic contains inappropriate language like '" + badword + "'. Please go back and try again.");

                var forumsDetails = new ForumsDetails()
                {
                    Body = topicBody.Trim(),
                    Name = topicTitle.Trim(),
                    LibraryName = topicForumPath.Trim()
                };
                ForumService.CreateNewTopic(forumsDetails);

                var forumsList = ForumService.GetForumSummary(1);
                var model = CreateList(forumsList).OrderByDescending(a => a.CreatedDate);
                var topicLink = model.FirstOrDefault(x => x.Name == topicTitle);

                var link = Request.Url.OriginalString.Replace(Request.Url.PathAndQuery, string.Empty).Replace("..", ".") + "/Forums/CommentList?strId=" + topicLink.Id + "&LibraryName=" + topicLink.LibraryName.Replace("/", "_") + "&ParentFolderPath=" + topicLink.ParentFolderPath + "&topicName=" + topicLink.Name + "";
                
                ForumSubscriptionService.SendNewTopicMailToModerator(topicForumPath, topicTitle, topicBody, topicForumPath.ForumSplit().ForumJoin(), link);

                ForumSubscriptionService.SendNewTopicSubscriptionMail(topicForumPath, topicTitle, topicBody, link);
                  Task.Factory.StartNew(() => ForumService.UpdateForumSummaryCache(true));
                return Content("A new topic '" + topicTitle + "' has been added successfully.");
            }
            catch (Exception exception)
            {
                return Content(exception.Message);
            }
        }
        private ForumsDetailsModel ConvertToForumDetailsModel(ForumsDetails forums)
        {
            var account = new AccountInfo();
            var accounType = typeof(AccountInfo);
            account.Department = account.GetDepartment();
            account.physicalDeliveryOfficeName = account.GetLocation();

            var forumDetails = GetForumsDetailsModel(forums);
            var subscription = ForumSubscriptionService.GetAllSubscriptions();
            var departmentForum = ForumActiveDirectoryMappingService.GetForumDepartmentMappings(accounType.GetProperty("Department").Name, account.GetDepartment());
            var locationForum = ForumActiveDirectoryMappingService.GetForumDepartmentMappings(accounType.GetProperty("physicalDeliveryOfficeName").Name, account.GetLocation());

            var nodeIsSubscribed = false;
            foreach (var subscriptionItem in subscription)
            {
                if (subscriptionItem.EmployeeName == account.GetUserName() && subscriptionItem.ForumName == forums.ForumFullPath)
                    nodeIsSubscribed = subscriptionItem.IsSubscribed;
            }
            forumDetails.IsSubscribed = nodeIsSubscribed;
            foreach (var names in departmentForum)
            {
                if (names == forums.ForumFullPath)
                    forumDetails.Department = names;
            }
            foreach (var location in locationForum)
            {
                if (location == forums.ForumFullPath)
                    forumDetails.Department = location;
            }
            forumDetails.CommentCount = forums.CommentCount;
            return forumDetails;
        }
        public ActionResult RouteToSerchedForums(string folderPath, string parent, string topicName, int replyId)
        {
            try
            {
                var forum = new ForumsDetails() { FolderPath = folderPath };
                var forumModel = ForumService.GetForumsByPath(forum);

                if (string.IsNullOrEmpty(topicName))
                {
                    foreach (var item in forumModel.SubForums)
                    {
                        forumModel.Children.AddRange(ForumService.GetForumsCommentList(item));
                    }

                    var replyModel = GetForumsDetailsModel(forumModel.Children.FirstOrDefault(x => x.RepliedId == replyId));

                    TempData["ForumSearch"] = replyModel;
                    return RedirectToAction("SearchResult", new { parent = forumModel.LibraryName, topicName });
                }

                var subitem = forumModel.SubForums.FirstOrDefault(x => String.Equals(x.Name, topicName, StringComparison.CurrentCultureIgnoreCase));
                subitem.Children.AddRange(ForumService.GetForumsCommentList(subitem));

                var model = GetForumsDetailsModel(subitem);
                foreach (var child in subitem.Children)
                {
                    model.Children.Add(GetForumsDetailsModel(child));
                }

                TempData["ForumSearch"] = model;
                return RedirectToAction("SearchResult", new { parent = model.LibraryName, topicName });
            }
            catch (Exception ex) { throw ex; }
        }
        public ActionResult CommentList(string strId, string LibraryName, string ParentFolderPath, string topicName)
        {
            try
            {
                var forum = new ForumsDetails { Id = new Guid(strId), LibraryName = LibraryName, ParentFolderPath = ParentFolderPath };

                var forumModel = ForumService.GetForums(forum);
                var forums = ConvertToForumDetailsModel(forumModel);
                forums.ParentId = new Guid(strId);

                forums.Children = CreateList(ForumService.GetForumsCommentList(forumModel), strId);
              
              
                return View(forums);
            }
            catch (Exception ex) { throw ex; }
        }
 private ForumsDetailsModel GetForumsDetailsModel(ForumsDetails forums)
 {
     var account = new AccountInfo();
     SetFullNameAndEmail();
     string imageFile = AppDomain.CurrentDomain.BaseDirectory + "/content/img/DefaultUser.png";
     var buffer = string.IsNullOrEmpty(forums.ProfileImgUrl) ? imageFile : forums.ProfileImgUrl;
     return new ForumsDetailsModel()
     {
         Name = forums.Name,
         DisplayName = forums.Name,
         LibraryName = forums.LibraryName,
         FolderPath = forums.FolderPath,
         Body = forums.Body,
         Id = forums.Id,
         CreatedBy = forums.CreatedBy,
         EditedBy = forums.EditedBy,
         CreatedDate = forums.CreatedDate,
         ParentFolderPath = forums.ParentFolderPath,
         TrimmedBody = forums.TrimmedBody,
         Replies = forums.Replies,
         LastUpdated = forums.LastUpdated,
         ModifiedDate = forums.ModifiedDate,
         ParentId = forums.ParentId,
         Permission = new SPPermissionModel() { CanAdd = forums.Permission.CanAdd },
         RootReply = forums.RootReply,
         Type = forums.Type,
         ProfileImgUrl = buffer,
         ForumFullPath = forums.ForumFullPath,
         EmployeeName = account.GetUserName(),  //User.Identity.Name,
         EmployeeEmail = account.GetEmailAddress(),
         IsSubscribed = false
     };
 }
Example #10
0
 public bool CreateNewTopic(ForumsDetails forums)
 {
     return ForumsDao.CreateNewTopic(forums);
 }
        public ActionResult SaveReply(FormCollection collection)
        {
            var replyValue = collection.Get("txtareaBody");
            var libraryName = collection.Get("hdnLibName");
            var parentFolderPath = collection.Get("hdnParentFolderPath");
            var id = new Guid(collection.Get("hdnGuid"));
            var body = collection.Get("hdnBody");
            var formatedBody = collection.Get("hdnFormatedBody");
            var replyForumsId = collection.Get("hdnReplyForumsId");
            var replyForumsPath = collection.Get("hdnReplyForumsPath");

            string topicName;
            //validate for bad words
            string badword;
            var badWordList = ForumSubscriptionService.GetBadWords();
            if (Helper.ContainsBadWords(replyValue, badWordList, out badword))
                throw new Exception("Your reply contains inappropriate language like '" + badword + "'. Please go back and reply again.");
            try
            {
                ForumsDetails forum;
                if (replyForumsId == string.Empty && replyForumsPath == string.Empty)
                    forum = new ForumsDetails() { Id = id, LibraryName = libraryName, ParentFolderPath = parentFolderPath };
                else
                    forum = new ForumsDetails() { Id = new Guid(replyForumsId), LibraryName = libraryName, ParentFolderPath = replyForumsPath };

                var forumModel = ForumService.GetForums(forum);
                if (forumModel == null)
                    throw new Exception("The comment you are trying to reply on does not exists.");

                forumModel.Body = "<div>" + replyValue + formatedBody + body + "</div>";
                forumModel.TrimmedBody = "<div>" + replyValue + "<br /></div>";

                topicName = forumModel.Name;
                var obj = new ForumsDetails() { Id = forumModel.Id, FolderPath = forumModel.FolderPath, LibraryName = forumModel.LibraryName, Name = forumModel.Name, Body = forumModel.Body, ParentFolderPath = forumModel.ParentFolderPath, TrimmedBody = forumModel.TrimmedBody, ParentId = id };

                var link = Request.Url.OriginalString.Replace(Request.Url.PathAndQuery, string.Empty) + "/Forums/CommentList?strId=" + id + "&LibraryName=" + libraryName + "&ParentFolderPath=" + parentFolderPath + "&topicName=" + obj.Name + "";

                ForumSubscriptionService.SendReplySubscriptionMail(forumModel.LibraryName, forumModel.Name,
                    forumModel.Body, link);


                var status = ForumService.ReplyForum(obj);
                
            }
            catch (Exception ex) { throw ex; }

            Task.Factory.StartNew(() => ForumService.UpdateForumSummaryCache(true));
            
            return RedirectToAction("CommentList", new { strId = id, LibraryName = libraryName, topicName, ParentFolderPath = parentFolderPath });
        }
Example #12
0
 public bool IsForumExist(ForumsDetails forumsDetails)
 {
     return ForumsDao.IsForumExist(forumsDetails);
 }
Example #13
0
 public ForumsDetails GetForumsByPath(ForumsDetails forumsDetails)
 {
     return ForumsDao.GetForumsByPath(forumsDetails);
 }
Example #14
0
 public ForumsDetails GetForums(ForumsDetails forumsDetails)
 {
     return ForumsDao.GetForums(forumsDetails);
 }
Example #15
0
 public bool ReplyForum(ForumsDetails forums) {
     return ForumsDao.ReplyForum(forums);
 }
Example #16
0
 public List<ForumsDetails> GetForumsCommentList(ForumsDetails forumsDetails)
 {
     return ForumsDao.GetForumsCommentList(forumsDetails);
 }