public async Task <ActionResult <WatchlistDto> > Patch(long id, [FromBody] JsonPatchDocument <WatchlistPatchDto> watchlistPatch)
    {
        Watchlist watchlist = await _manager.GetByIdAsync(id);

        var watchlistDto = _mapper.Map <WatchlistPatchDto>(watchlist);

        string userId = User.FindFirstValue(ClaimTypes.NameIdentifier) ?? throw new InvalidPermissionException(ErrorCode.InvalidUserId);

        if (watchlist.UserId != userId)
        {
            throw new InvalidPermissionException(ErrorCode.InvalidPermissionMarket);
        }

        watchlistPatch.ApplyTo(watchlistDto);

        watchlist = _mapper.Map <WatchlistPatchDto, Watchlist>(watchlistDto,
                                                               opt => opt.AfterMap((src, dest) =>
        {
            dest.Id               = watchlist.Id;
            dest.UserId           = watchlist.UserId;
            dest.MarketWatchlists = watchlist.MarketWatchlists;
        }));

        var entity = await _manager.UpdateAsync(watchlist);

        var           dto  = _mapper.Map <WatchlistDto>(entity);
        WatchlistDtoI dtoI = _mapper.Map <WatchlistDtoI>(dto);

        _messageBus.Publish(dtoI, "exc.Market", RabbitExchangeType.DirectExchange, $"Update:{userId}");
        return(Ok(dto));
    }
    public async Task <ActionResult <WatchlistDto> > Post(WatchlistPostDto item)
    {
        if (!_validator.Validate(item).IsValid)
        {
            return(BadRequest());
        }

        string userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

        Watchlist watchlist = _mapper.Map <WatchlistPostDto, Watchlist>(item);

        watchlist.UserId = userId ?? throw new InvalidPermissionException(ErrorCode.InvalidUserId);

        var entity = await _manager.CreateAsync(watchlist);

        WatchlistDto  dto  = _mapper.Map <WatchlistDto>(entity);
        WatchlistDtoI dtoI = _mapper.Map <WatchlistDtoI>(dto);

        _messageBus.Publish(dtoI, "exc.Market", RabbitExchangeType.DirectExchange, $"Add:{userId}");
        return(Ok(dto));
    }