async Task IGameResultRepository.AddGameResult(
            Guid deckID,
            Models.Client.GameResult gameResult)
        {
            using (await _asyncMutex.WaitAsync().ConfigureAwait(false))
            {
                await _deckFileStorage.SaveAll(
                    (await _deckFileStorage.GetAll().ConfigureAwait(false))
                    .Select(
                        __deck =>
                {
                    if (__deck.DeckID != deckID)
                    {
                        return(__deck);
                    }

                    return
                    (new Models.Data.Deck(
                         __deck.DeckID,
                         __deck.DeckString,
                         __deck.Title,
                         __deck.Position,
                         __deck.GameResults.Append(
                             new Models.Data.GameResult(
                                 gameResult.Timestamp,
                                 gameResult.GameWon,
                                 gameResult.OpponentClass))));
                })).ConfigureAwait(false);
            }
        }
Example #2
0
        async Task IDeckRepository.UpdateDeck(
            Models.Client.DeckDetail deckDetail)
        {
            using (await _asyncMutex.WaitAsync().ConfigureAwait(false))
            {
                await _deckFileStorage.SaveAll(
                    (await _deckFileStorage.GetAll().ConfigureAwait(false))
                    .Select(
                        __deck =>
                {
                    if (__deck.DeckID != deckDetail.DeckID)
                    {
                        return(__deck);
                    }

                    return
                    (new Models.Data.Deck(
                         deckDetail.DeckID,
                         deckDetail.DeckString,
                         deckDetail.Title,
                         deckDetail.Position,
                         __deck.GameResults));
                })).ConfigureAwait(false);
            }
        }