private async Task BeginCardImpression() { this.lock_cardMutation.EnterWriteLock(); try { var nextCardToTest = await this.flashcardSessionTestingService.GetNextFlashcard(); this.IsFlipped = nextCardToTest.CardSideToTest == CardSide.Front; this.IsRevealed = false; this.Card = await this.cardStorageService.GetCard(nextCardToTest.CollectionId, nextCardToTest.CardId); this.currentImpression = new CardImpression { CardId = nextCardToTest.CardId, Date = DateTime.Now, TestedSide = nextCardToTest.CardSideToTest }; impressionStopwatch.Restart(); } finally { this.lock_cardMutation.ExitWriteLock(); } this.CardUpdated?.Invoke(); }
public async Task AddImpression(CardImpression impression) { using (var context = new MainDatabaseContext()) { await context.CardImpressions.AddAsync(impression); await context.SaveChangesAsync(); } }