public IActionResult OnPostDeleteComment([FromRoute] int id, [FromForm] Comment comment) { _commentsService.DeleteComment(comment.Id); OnGet(id); return(RedirectToPage()); }
public async Task <ActionResult> DeleteComment(int commentId) { var user = await _userManager.GetUserAsync(HttpContext.User); var deletedComment = _commentsService.DeleteComment(commentId, user); return(RedirectToAction(nameof(GetComments), new { deletedComment.ResponseId })); }
public void Register(string userName, int filmId) { if (commentsService.DeleteComment(userName, filmId)) { Response.Write("1"); } else { Response.Write("0"); } Response.End(); }
public async Task <IActionResult> DeleteComment(int commentId) { try { var user = await _userManager.GetUserAsync(HttpContext.User); _commentsService.DeleteComment(commentId, user); return(Ok()); } catch (Exception) { return(BadRequest()); } }
public async Task <ActionResult <Comment> > DeleteComment(int id) { try { Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>(); _service.DeleteComment(id, userInfo.Id); return(Ok("Comment Deleted")); } catch (Exception e) { return(BadRequest(e.Message)); } }
public void ReturnResultErrorIfNoCommentExists() { //Arrange var guid = Guid.NewGuid(); commentsRepo.Setup(x => x.GetById(It.IsAny <Guid>())).Returns((Comments)null); var sut = new CommentsService(movies.Object, genresRepo.Object, commentsRepo.Object, userRepo.Object, likesRepo.Object, dislikesRepo.Object, saver.Object); //Act var result = sut.DeleteComment(guid, "test"); //Assert Assert.AreEqual(result.ResulType, ResultType.DoesntExists); Assert.AreEqual(result.ErrorMsg, Constants.ErorsDict[ResultType.DoesntExists]); }
public async Task DeleteComment(int commentID) { using (Db) { await Db.Connection.OpenAsync(); User v = new User(Db) { ID = 1, Username = "******", Password = "******", Email = "*****@*****.**", }; await CS.DeleteComment(commentID); } }
public void DeleteCommentDeletesTheWriteComment() { var options = new DbContextOptionsBuilder <DealershipDbContext>() .UseInMemoryDatabase(databaseName: "Delete_Comment") .Options; var db = new DealershipDbContext(options); var newsService = new NewsService(db); var commentsService = new CommentsService(db); var news = newsService.CreateNews(GetNewsCreateInputModel(), AuthorId); Assert.True(news.Comments.Count() == 0); var comment = commentsService.Create(AuthorId, news.Id, Content); Assert.True(news.Comments.Count() == 1); commentsService.DeleteComment(comment.Id); Assert.True(news.Comments.Count() == 0); }
public async Task <ActionResult> DeleteComment(int id) { await _service.DeleteComment(id); return(Json("OK")); }
public IActionResult DeleteConfirmed(Guid id) { _service.DeleteComment(id); return(RedirectToAction(nameof(Index))); }