Exemplo 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);
        }
Exemplo n.º 2
0
 /// <summary>
 ///   Adds to database.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns></returns>
 protected async Task <bool> AddToDbAsync(T item)
 {
     return(await _db.InsertAsync(item).ConfigureAwait(false) > 0);
 }
        /// <summary>Creates the specified current query.</summary>
        /// <param name="query">The current query.</param>
        /// <returns></returns>
        public async Task CreateAsync(CollectionQuery query)
        {
            await _db.InsertAsync(query).ConfigureAwait(false);

            CollectionQueries.Queries.Add(query);
        }