Example #1
0
        public void AdicionarResposta(RespostaCommand command)
        {
            if (command.CodigoAlternativa.HasValue)
            {
                if (!_alternativaRepository.Exists(command.CodigoPergunta, command.CodigoAlternativa.Value))
                {
                    throw new ValidateException("Alternativa não encontrada.");
                }
            }
            else if (!_perguntaRepository.Exists(command.CodigoPergunta))
            {
                throw new ValidateException("Pergunta não encontrada.");
            }

            _respostaRepository.ExcluirResposta(_usuario.Codigo.GetValueOrDefault(0), command.CodigoPergunta);

            _respostaRepository.Add(new EnqResposta
            {
                CodigoPergunta    = command.CodigoPergunta,
                CodigoAlternativa = command.CodigoAlternativa,
                CodigoContato     = _usuario.Codigo.GetValueOrDefault(0)
            });
        }