public async Task IncreaseScoreAsync(string userId, int additionalScore) { var entity = await storageAccessService.GetTableEntityAsync <UserStatsTableEntity>(TableNames.UserStats, StaticPartitionKeys.UserStats, userId); if (entity.Score == null) { entity.Score = 0; } entity.Score += additionalScore; await storageAccessService.ReplaceAsync(TableNames.UserStats, entity); }
public async Task UpdateDrinkEventAsync(Domain.DrinkEvent drinkEvent) { string rowKey = GetRowKey(drinkEvent.EndUtc); var entity = await storageAccessService.GetTableEntityAsync <JsonTableEntity <DrinkEventEntity> >(TableNames.DrinkEvents, StaticPartitionKeys.DrinkEvent, rowKey); entity.Entity = drinkEvent.ToEntity(); await storageAccessService.ReplaceAsync(TableNames.DrinkEvents, entity); }
public async Task <InvitationTableEntity> GetAsync(Guid invitationToken) { var invitationEntity = await storageAccess.GetTableEntityAsync <InvitationTableEntity>(TableNames.Invitations, StaticPartitionKeys.Invitation, invitationToken.ToString()); if (invitationEntity == null) { throw new NotFoundException($"Invitation [{invitationToken}] not found!"); } return(invitationEntity); }
public async Task <UserStatistics> GetStatisticsAsync(string userId) { var result = await storageAccessService.GetTableEntityAsync <UserStatsTableEntity>(TableNames.UserStats, StaticPartitionKeys.UserStats, userId); if (result != null) { return(new UserStatistics(userId, result.CurrentAlcoholization, result.CurrentNightDrinks, result.Score, result.TotalDrinksLastMonth)); } else { return(new UserStatistics(userId)); } }