Esempio n. 1
0
        public ActionResult NewParentReply(string replyBody, string comUserName, string commentid, string slug)
        {
            var comDelChck = CommentDeleteCheck(commentid);

            if (!comDelChck)
            {
                List <int> numlist = new List <int>();
                int        num     = 0;
                var        replies = _blogRepository.GetReplies().ToList();
                if (replies.Count != 0)
                {
                    foreach (var rep in replies)
                    {
                        var repid = rep.Id;
                        Int32.TryParse(repid.Replace("rep", ""), out num);
                        numlist.Add(num);
                    }
                    numlist.Sort();
                    num = numlist.Last();
                    num++;
                }
                else
                {
                    num = 1;
                }
                var newid = "rep" + num.ToString();
                var reply = new Reply()
                {
                    Id            = newid,
                    CommentId     = commentid,
                    ParentReplyId = null,
                    DateTime      = DateTime.Now,
                    UserName      = comUserName,
                    Body          = replyBody,
                };
                _blogRepository.AddNewReply(reply);
            }

            var pageId = _blogRepository.GetPageIdByComment(commentid);

            if (pageId.Contains("post"))
            {
                return(RedirectToAction("Post", new { slug = slug }));
            }
            else
            {
                return(RedirectToAction("Index", "Blog"));
            }
        }