public DeleteASuggestionCommentValidationContext(DeleteASuggestionCommentCommand command, ISuggestionRepository repository) { Command = command; Repository = repository; RepositoryValidationContext = new CommonSuggestionRepositoryValidationContext(repository, Command.SuggestionId); RepositoryValidationContext.CommentId = Command.Id; }
public void Setup() { var validCommand = new DeleteASuggestionCommentCommand { Id = Guid.NewGuid(), SuggestionId = Guid.NewGuid(), UserId = "any value" }; _repository = new SuggestionRepository(_dbContext); _validationContext = new DeleteASuggestionCommentValidationContext(validCommand, _repository); }
public async Task <Suggestion> Handle(DeleteASuggestionCommentCommand deleteASuggestionComment, CancellationToken cancellationToken = default) { var validationContext = new DeleteASuggestionCommentValidationContext(deleteASuggestionComment, _repository); _deleteCommentValidator.Validate(validationContext); var suggestion = _repository.RemoveUserComment(deleteASuggestionComment.SuggestionId, deleteASuggestionComment.Id, deleteASuggestionComment.UserId); await _dbContext.SaveChangesAsync(); return(suggestion); }