Exemplo n.º 1
0
        public IActionResult ApproveComment(Guid postid, Guid commentid)
        {
            CommentSaveState state = blogManager.ApproveComment(postid.ToString(), commentid.ToString());

            if (state == CommentSaveState.Failed)
            {
                return(StatusCode(500));
            }

            if (state == CommentSaveState.NotFound)
            {
                return(NotFound());
            }

            return(Ok());
        }
Exemplo n.º 2
0
        public CommentSaveState ApproveComment(string postid, string commentid)
        {
            CommentSaveState est   = CommentSaveState.Failed;
            Entry            entry = dataService.GetEntry(postid);

            if (entry != null && !string.IsNullOrEmpty(commentid))
            {
                dataService.ApproveComment(postid, commentid);

                est = CommentSaveState.Approved;
            }
            else
            {
                est = CommentSaveState.NotFound;
            }

            return(est);
        }
Exemplo n.º 3
0
        public CommentSaveState AddComment(string postid, Comment comment)
        {
            CommentSaveState est = CommentSaveState.Failed;

            Entry entry = _dataService.GetEntry(postid);

            if (entry != null)
            {
                // Are comments allowed

                _dataService.AddComment(comment);

                est = CommentSaveState.Added;
            }
            else
            {
                est = CommentSaveState.NotFound;
            }

            return(est);
        }
Exemplo n.º 4
0
        public IActionResult AddComment(Guid postid, CommentViewModel comment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            Comment          commt = _mapper.Map <Comment>(comment);
            CommentSaveState state = _blogManager.AddComment(postid.ToString(), commt);

            if (state == CommentSaveState.Failed)
            {
                return(StatusCode(500));
            }

            if (state == CommentSaveState.NotFound)
            {
                return(NotFound());
            }

            return(Ok());
        }
Exemplo n.º 5
0
        public IActionResult AddComment(AddCommentViewModel addcomment)
        {
            if (!dasBlogSettings.SiteConfiguration.EnableComments)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                Comment(new Guid(addcomment.TargetEntryId));
            }

            Comment commt = mapper.Map <Comment>(addcomment);

            commt.AuthorIPAddress = HttpContext.Connection.RemoteIpAddress.ToString();
            commt.AuthorUserAgent = HttpContext.Request.Headers["User-Agent"].ToString();
            commt.CreatedUtc      = commt.ModifiedUtc = DateTime.UtcNow;
            commt.EntryId         = Guid.NewGuid().ToString();
            commt.IsPublic        = !dasBlogSettings.SiteConfiguration.CommentsRequireApproval;

            CommentSaveState state = blogManager.AddComment(addcomment.TargetEntryId, commt);

            if (state == CommentSaveState.Failed)
            {
                ModelState.AddModelError("", "Comment failed");
                return(StatusCode(500));
            }

            if (state == CommentSaveState.NotFound)
            {
                ModelState.AddModelError("", "Invalid comment attempt");
                return(NotFound());
            }

            return(Comment(new Guid(addcomment.TargetEntryId)));
        }