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()); }
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); }
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); }
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()); }
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))); }