private string GetVoteResult(string userId, string userName) { var votes = VoteRepository.GetVotes(userId); var vanilleCount = votes.Count(s => s.Equals("Vanille", StringComparison.InvariantCultureIgnoreCase)); var erdbeerCount = votes.Count(s => s.Equals("Erdbeer", StringComparison.InvariantCultureIgnoreCase)); var result = $"{userName} hat sich noch nicht entschieden"; if (vanilleCount > erdbeerCount) { result = $"{userName} mag eher Vanille. {vanilleCount}:{erdbeerCount}"; } if (vanilleCount < erdbeerCount) { result = $"{userName} mag eher Erdbeer. {erdbeerCount}:{vanilleCount}"; } if (vanilleCount != 0 && vanilleCount == erdbeerCount) { result = $"{userName} mag Erdbeer und Vanille. {erdbeerCount}:{vanilleCount}"; } return(result); }
public void Post([FromBody] Vote vote) { var userId = GetUserId(); VoteRepository.SetVote(userId, vote.Value); }