예제 #1
0
 public ActionResult NewChildReply(string preplyid, string comUserName, string replyBody)
 {
     var repDelCheck = ReplyDeleteCheck(preplyid);
     var preply = _blogRepository.GetReplyById(preplyid);
     if (!repDelCheck)
     {
         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,
             PostId = preply.PostId,
             CommentId = preply.CommentId,
             ParentReplyId = preply.Id,
             DateTime = DateTime.Now,
             UserName = comUserName,
             Body = replyBody,
         };
         _blogRepository.AddNewReply(reply);
     }
     return RedirectToAction("Post", new { slug = _blogRepository.GetPosts().Where(x => x.Id == preply.PostId).FirstOrDefault().UrlSeo });
 }
예제 #2
0
 public ActionResult NewParentReply(string replyBody, string comUserName, string postid, 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,
             PostId = postid,
             CommentId = commentid,
             ParentReplyId = null,
             DateTime = DateTime.Now,
             UserName = comUserName,
             Body = replyBody,
         };
         _blogRepository.AddNewReply(reply);
     }
     return RedirectToAction("Post", new { slug = slug });
 }
예제 #3
0
 public void AddNewReply(Reply reply)
 {
     _context.Replies.Add(reply);
     Save();
 }
예제 #4
0
 public List<CommentViewModel> GetChildReplies(Reply parentReply)
 {
     return _blogRepository.GetChildReplies(parentReply);
 }
예제 #5
0
 public List<CommentViewModel> GetChildReplies(Reply parentReply)
 {
     List<CommentViewModel> chldReplies = new List<CommentViewModel>();
     if (parentReply != null)
     {
         var childReplies = _context.Replies.Where(p => p.ParentReplyId == parentReply.Id).ToList();
         foreach (var reply in childReplies)
         {
             var chReplies = GetChildReplies(reply);
             chldReplies.Add(new CommentViewModel() { Body = reply.Body, ParentReplyId = reply.ParentReplyId, DateTime = reply.DateTime, Id = reply.Id, UserName = reply.UserName, ChildReplies = chReplies });
         }
     }
     return chldReplies;
 }