public async Task Handle(AccountUserNameUpdated notification, CancellationToken cancellationToken) { var tosses = (await(await cosmosDBTemplate.CreateDocumentQuery()) .Where(t => t.UserId == notification.User.Id) .AsDocumentQuery() .GetAllResultsAsync()) .ToList(); foreach (var item in tosses) { item.UserName = notification.User.UserName; await cosmosDBTemplate.Update(item); } }
public async Task Handle(SponsoredTossDisplayed notification, CancellationToken cancellationToken) { var toss = (await cosmosDBTemplate.CreateDocumentQuery()) .Where(t => t.Id == notification.TossId) .Take(1) .AsEnumerable() .FirstOrDefault(); //we displayed a now removed if (toss == null) { return; } toss.DecreaseDisplayCount(); await cosmosDBTemplate.Update(toss); }