From 733b66002356b73931c430eea51fa3b2c398deb0 Mon Sep 17 00:00:00 2001 From: ksetiono Date: Wed, 15 Jan 2020 23:03:38 +0100 Subject: [PATCH] Make sure that partition key is valid even if the name starts with a number or special character --- VotingWeb/Controllers/VotesController.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/VotingWeb/Controllers/VotesController.cs b/VotingWeb/Controllers/VotesController.cs index d10f3fa..fd2f7f4 100644 --- a/VotingWeb/Controllers/VotesController.cs +++ b/VotingWeb/Controllers/VotesController.cs @@ -126,7 +126,9 @@ private Uri GetProxyAddress(Uri serviceName) /// private long GetPartitionKey(string name) { - return Char.ToUpper(name.First()) - 'A'; + long partitionKey = Char.ToUpper(name.First()) - 'A'; + + return Math.Min(25, Math.Max(0, partitionKey)); } } } \ No newline at end of file