diff --git a/result/dotnet/Result/Data/MySqlResultData.cs b/result/dotnet/Result/Data/MySqlResultData.cs index 8a1cbbe..3c8ed67 100644 --- a/result/dotnet/Result/Data/MySqlResultData.cs +++ b/result/dotnet/Result/Data/MySqlResultData.cs @@ -26,11 +26,11 @@ namespace Result.Data var results = connection.Query("SELECT vote, COUNT(id) AS count FROM votes GROUP BY vote ORDER BY vote"); if (results.Any(x => x.vote == "a")) { - model.OptionA = results.First(x => x.vote == "a").count; + model.OptionA = (int) results.First(x => x.vote == "a").count; } if (results.Any(x => x.vote == "b")) { - model.OptionB = results.First(x => x.vote == "b").count; + model.OptionB = (int) results.First(x => x.vote == "b").count; } model.VoteCount = model.OptionA + model.OptionB; } diff --git a/result/dotnet/Result/Pages/Index.cshtml b/result/dotnet/Result/Pages/Index.cshtml index 21a992a..4b3dcdf 100644 --- a/result/dotnet/Result/Pages/Index.cshtml +++ b/result/dotnet/Result/Pages/Index.cshtml @@ -26,12 +26,12 @@
@Model.OptionA
-
+
50%
@Model.OptionB
-
+
50%
diff --git a/result/dotnet/Result/wwwroot/js/results.js b/result/dotnet/Result/wwwroot/js/results.js index 015d5bf..e08e90d 100644 --- a/result/dotnet/Result/wwwroot/js/results.js +++ b/result/dotnet/Result/wwwroot/js/results.js @@ -11,10 +11,11 @@ connection.on("UpdateResults", function (results) { document.getElementById("optionA").innerText = percentages.a + "%"; document.getElementById("optionB").innerText = percentages.b + "%"; + var totalVotes = 'No votes yet'; if (results.voteCount > 0) { - var totalVotes = results.voteCount + (results.voteCount > 1 ? " votes" : " vote"); - document.getElementById("totalVotes").innerText = totalVotes; + totalVotes = results.voteCount + (results.voteCount > 1 ? " votes" : " vote"); } + document.getElementById("totalVotes").innerText = totalVotes; var bg1 = document.getElementById('background-stats-1'); var bg2 = document.getElementById('background-stats-2');