public async Task <IActionResult> DeleteComment([FromBody] DeleteCommentDto comment) { var service = new PostService(); var result = await service.DeleteCommentAsync(comment, UserId); return(FromResult(result)); }
public async Task DeleteAsync(DeleteCommentDto dto, bool isAdmin = false) { var token = await GetAccessTokenAsync(); await($"{_apiOptions.Url}/api/AdvertComment").WithOAuthBearerToken(token) .SetQueryParams(dto).DeleteAsync(); }
public async Task <IActionResult> DeleteObjectComment([FromBody] DeleteCommentDto deleteCommentDto) { var result = await _commentService.AuthorizedDeleteComment(deleteCommentDto); return(StatusCode(result, new { Message = "The comment has been deleted" })); }
public async Task <Result> DeleteCommentAsync(DeleteCommentDto comment, string userId) { return(await _deleteCommentCommandHandler.HandleAsync(new DeleteCommentCommand() { CommentId = comment.CommentId, TopLevel = comment.TopLevel, PostUrl = comment.PostUrl })); }
public async Task <IActionResult> Delete(int IDRecruiter, int IDJobSeeker, bool isRecruiterWrite) { DeleteCommentDto input = new DeleteCommentDto() { IDRecruiter = IDRecruiter, IDJobSeeker = IDJobSeeker, isRecruiterWrite = isRecruiterWrite }; await _commentServiceAppService.DeleteCommentAsync(input); return(NoContent()); }
public async Task <CommandResult> AuthorizedDeleteComment(DeleteCommentDto deleteCommentDto) { if (deleteCommentDto == null || deleteCommentDto.CommentId.IsNullOrEmpty()) { return(new CommandResult(new ErrorMessage { ErrorCode = "CATALOG.OBJECT.COMMENT.DELETE.NULL", Message = "Please send a valid data", StatusCode = System.Net.HttpStatusCode.BadRequest })); } if (!Guid.TryParse(deleteCommentDto.CommentId, out var commentIdGuid)) { return(new CommandResult(new ErrorMessage { ErrorCode = "CATALOG.OBJECT.COMMENT.DELETE.INVALID.ID", Message = "Please send a valid data", StatusCode = System.Net.HttpStatusCode.BadRequest })); } var comment = _commentRepo.Table.SingleOrDefault(c => c.ObjectCommentId == commentIdGuid); if (comment == null) { return(new CommandResult(new ErrorMessage { ErrorCode = "CATALOG.OBJECT.COMMENT.DELETE.INVALID.ID", Message = "The comment you are trying to delete does not exists", StatusCode = System.Net.HttpStatusCode.BadRequest })); } try { _commentRepo.Delete(comment); await _commentRepo.SaveChangesAsync(); return(new CommandResult()); } catch (Exception e) { _logger.LogError(e, $"There were a problem deleting the object:{deleteCommentDto.CommentId}"); return(new CommandResult(new ErrorMessage { ErrorCode = "CATALOG.OBJECT.DELETE.INTERNAL.ERROR", Message = "There were an error deleting your object", StatusCode = System.Net.HttpStatusCode.InternalServerError })); } }
public async Task DeleteCommentAsync(DeleteCommentDto input) { // this.AbpSession.UserId; var commentUpdateOrDeleteDto = new CreateOrUpdateCommentDto() { IDJobSeeker = input.IDJobSeeker, IDRecruiter = input.IDRecruiter, IsRecruiterWrite = input.isRecruiterWrite, Reason = "", Description = "", StarNumber = null }; await CreateOrUpdateCommentAsync(commentUpdateOrDeleteDto); }
public async Task DeleteAsync(DeleteCommentDto dto, bool isAdmin = false) { AdvertComment comment = await _unitOfWork.AdvertCommentRepository.GetAsync(dto.Id); ThrowIfNotFound(comment); if (!isAdmin && comment.UserId != dto.UserId) { throw new NotPermittedException("Нельзя удалять чужие комментарии"); } _unitOfWork.AdvertCommentRepository.Delete(comment); _unitOfWork.SaveChanges(); }
public async Task DeleteComment([FromQuery] DeleteCommentDto dto) { dto.UserId = User.GetUserId(); await _advertCommentService.DeleteAsync(dto, User.IsInRole("Admin")); }
public async Task <IActionResult> DeleteComment([FromForm] DeleteCommentDto comment) { await _commentService.DeleteAsync(comment); return(RedirectToAction("Get", "Advert", new { id = comment.AdvertId })); }