Example #1
0
        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();
        }
Example #3
0
        public async Task <IActionResult> DeleteObjectComment([FromBody] DeleteCommentDto deleteCommentDto)
        {
            var result = await _commentService.AuthorizedDeleteComment(deleteCommentDto);

            return(StatusCode(result, new
            {
                Message = "The comment has been deleted"
            }));
        }
Example #4
0
 public async Task <Result> DeleteCommentAsync(DeleteCommentDto comment, string userId)
 {
     return(await _deleteCommentCommandHandler.HandleAsync(new DeleteCommentCommand()
     {
         CommentId = comment.CommentId,
         TopLevel = comment.TopLevel,
         PostUrl = comment.PostUrl
     }));
 }
Example #5
0
        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());
        }
Example #6
0
        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
                }));
            }
        }
Example #7
0
        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);
        }
Example #8
0
        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();
        }
Example #9
0
        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 }));
        }