コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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));
            }
        }