Ejemplo n.º 1
0
        private void SaveVote(object sender, MsgHandlerEventArgs e)
        {
            _logger.LogDebug($"Received message, subject: {e.Message.Subject}");
            var voteMessage = MessageHelper.FromData <VoteCastEvent>(e.Message.Data);

            _logger.LogInformation($"Processing vote for '{voteMessage.Vote}' by '{voteMessage.VoterId}'");
            try
            {
                _data.Set(voteMessage.VoterId, voteMessage.Vote);
                _logger.LogInformation($"Succesfully processed vote by '{voteMessage.VoterId}'");
            }
            catch (Exception ex)
            {
                _logger.LogError($"Vote processing FAILED for '{voteMessage.VoterId}', exception: {ex}");
            }
        }
Ejemplo n.º 2
0
        private void SaveVote(string json)
        {
            var definition  = new { vote = "", voter_id = "" };
            var voteMessage = JsonConvert.DeserializeAnonymousType(json, definition);

            _logger.LogInformation($"Processing vote for '{voteMessage.vote}' by '{voteMessage.voter_id}'");
            try
            {
                _data.Set(voteMessage.voter_id, voteMessage.vote);
                _logger.LogDebug($"Successfuly processed vote by '{voteMessage.voter_id}'");
            }
            catch (Exception ex)
            {
                _logger.LogError($"Vote processing FAILED for '{voteMessage.voter_id}', exception: {ex}");
            }
        }