async Task <bool> ICardService.ToggleFavouriteAsync(int id, int userId, CancellationToken cancellationToken) { var cards = await _cardRepository.FindCardsAsync( new Data.Abstractions.CardSearchFilter { Ids = new int[] { id, }, UserId = userId, }, cancellationToken : cancellationToken ); var card = cards.Results.FirstOrDefault(); if (card == null) { throw new InvalidCardException($"Card { id } does not exist."); } await _cardRepository.FavouriteCardAsync(id, userId, !card.IsFavourited, cancellationToken : cancellationToken); return(!card.IsFavourited); }