Task UpdateStatusAsync(Guid id, WatchStatus status, CancellationToken cancellationToken) { if (this.watches.TryGetValue(id, out var watchWithStatus)) { watchWithStatus.Status = status; return(Task.CompletedTask); } throw new KeyNotFoundException("Watch Id is not exist."); }
async Task UpdateStatusAsync(Guid id, WatchStatus status, CancellationToken cancellationToken) { using (var db = this.db.CreateDbContext()) { var watch = await db.TransactionConfirmationWatcherWatches .Where(w => w.Id == id) .SingleAsync(cancellationToken); watch.Status = status; await db.SaveChangesAsync(cancellationToken); } }
async Task <IEnumerable <DomainModel> > ListAsync( WatchStatus status, uint256 startBlock, CancellationToken cancellationToken) { IEnumerable <EntityModel> entities; using (var db = this.db.CreateDbContext()) { IQueryable <EntityModel> query = db.TransactionConfirmationWatcherWatches .Include(w => w.Rule) .ThenInclude(r => r.Callback); query = (startBlock != null) ? query.Where(w => w.Status == status && w.StartBlockHash == startBlock) : query.Where(w => w.Status == status); entities = await query.ToListAsync(cancellationToken); } return(entities.Select(e => ToDomain(e)).ToList()); }