void ApplyReputationChange(string appName, string objectId, string stat, string modifier, string description)
        {
            int modVal;
            if (!int.TryParse(modifier.Trim('+'), out modVal) || modVal == 0)
                return;

            // get previous total for this stat
            var tblTotal = AzureTable.Get("reputationtotals");
            TableOperation retrieveOperation = TableOperation.Retrieve<ReputationTotal>(appName, objectId);
            TableResult retrievedResult = tblTotal.Execute(retrieveOperation);

            // Print the phone number of the result.
            if (retrievedResult.Result != null) {
                AddStat((retrievedResult.Result as ReputationTotal), stat, modVal);
                tblTotal.Execute(TableOperation.Replace(retrievedResult.Result as ReputationTotal));
            } else {
                var total = new ReputationTotal(appName, objectId);
                AddStat(total, stat, modVal);
                tblTotal.Execute(TableOperation.Insert(total));
            }

            var tblChanges = AzureTable.Get("reputationchanges");
            TableOperation insertOperation = TableOperation.Insert(new ReputationEntry(appName) {
                Object = objectId,
                Stat = stat,
                Description = description ?? "",
                Modifier = modVal,
            });
            tblChanges.Execute(insertOperation);
        }
 void AddStat(ReputationTotal total, string stat, int val)
 {
     switch (stat) {
         case "Quality":
             total.TotalQuality += val;
             break;
         case "Quantity":
             total.TotalQuantity += val;
             break;
         case "Trust":
             total.TotalTrust += val;
             break;
     }
 }