Esempio n. 1
0
 public PhotoScore GetBestScore()
 {
     if (scores.Count == 0)
     {
         // timer ran out, no photos
         return(new PhotoScore(null, 0));
     }
     else
     {
         PhotoScore best = scores[0];
         foreach (PhotoScore score in scores)
         {
             if (score.score > best.score)
             {
                 best = score;
             }
         }
         return(best);
     }
 }
        private UpdateItemRequest GetScoreUpdateRequest(PhotoScore score)
        {
            return(new UpdateItemRequest()
            {
                TableName = tableName,
                Key = Mappers.PhotoModel.ToDbKey(new PhotoModel {
                    PhotoId = score.PhotoId
                }),
                ExpressionAttributeNames = new Dictionary <string, string>
                {
                    { "#Score", FieldMappings.Photo.Score }
                },
                ExpressionAttributeValues = new Dictionary <string, AttributeValue>
                {
                    { ":score", new AttributeValue {
                          N = score.Score.ToString()
                      } }
                },
                UpdateExpression = "SET #Score = :score",

                // make the dynamodb layer log consumed capacity for this request
                ReturnConsumedCapacity = ReturnConsumedCapacity.INDEXES
            });
        }