Esempio n. 1
0
        private async Task UpdateCardAsync(ReviewLog log, Card card, CardAction cardAction)
        {
            Task[] tasks;
            Task   logTask        = _db.InsertAsync(log);
            Task   cardUpdateTask = _db.UpdateAsync(card);

            if (cardAction == CardAction.Dismiss || cardAction == CardAction.Delete)
            {
                tasks = new[] { cardUpdateTask, logTask }
            }
            ;

            else
            {
                Task siblingsTask =
                    _db.QueryAsync <Card>(
                        @"UPDATE """ + _cardTableName + @""" SET ""Due"" = ? WHERE ""Due"" < ?"
                        + @" AND ""NoteId"" = ? AND ""Id"" <> ?",
                        DateTimeExtensions.Tomorrow.ToUnixTimestamp(),
                        DateTimeExtensions.Tomorrow.ToUnixTimestamp(), card.NoteId, card.Id);

                tasks = new[] { cardUpdateTask, logTask, siblingsTask };
            }

            await Task.WhenAll(tasks).ConfigureAwait(false);
        }