示例#1
0
 public TrofeuDTO(Trofeu trofeu) : this()
 {
     Id        = trofeu.Id;
     IdCase    = trofeu.IdCase;
     Nome      = trofeu.Nome;
     Descricao = trofeu.Descricao;
     Pontos    = trofeu.Pontos;
 }
示例#2
0
        public EntregaDeTrofeu(Trofeu trofeu, EntregaDeLicao entregaDeLicao, Resposta resposta)
        {
            IdTrofeu         = trofeu.Id;
            IdEntregaDeLicao = entregaDeLicao.Id;

            if (resposta != null)
            {
                IdResposta = resposta.Id;
            }
        }
示例#3
0
        public void Atribuir(AtribuirTrofeuRequest request, Usuario usuario)
        {
            Trofeu trofeu = _trofeuRepository.GetById(request.IdTrofeu);

            if (trofeu == null)
            {
                throw new Exception("Troféu não localizado.");
            }

            CaseDeNegocio caseDeNegocio = _caseDeNegocioService.ObterPorId(trofeu.IdCase);

            if (!_caseDeNegocioService.UsuarioEstaAssociadoAoCaseDeNegocioComoProfessor(usuario, caseDeNegocio))
            {
                throw new Exception("Usuário não possui permissão para esta solicitação.");
            }

            EntregaDeLicao entregaDeLicao = _entregaDeLicaoRepository.GetById(request.IdEntregaDeLicao);

            if (entregaDeLicao == null)
            {
                throw new Exception("Lição não localizada.");
            }
            else if (entregaDeLicao.Licao.IdCase != caseDeNegocio.Id)
            {
                throw new Exception("Lição não pode ser associada à este troféu.");
            }

            Resposta resposta = null;

            if (request.IdResposta != null && request.IdResposta > 0)
            {
                resposta = _respostaRepository.GetById(request.IdResposta.Value);
                if (resposta == null)
                {
                    throw new Exception("Questão não localizada.");
                }
                else if (resposta.IdEntregaDeLicao != entregaDeLicao.Id)
                {
                    throw new Exception("Resposta não associada à lição.");
                }
            }

            EntregaDeTrofeu entregaDeTrofeu = new EntregaDeTrofeu(trofeu, entregaDeLicao, resposta);

            Adicionar(entregaDeTrofeu);
        }
示例#4
0
 public void PreencherEntidade(Trofeu trofeu)
 {
     trofeu.Nome      = Nome;
     trofeu.Descricao = Descricao;
     trofeu.Pontos    = Pontos;
 }
示例#5
0
 public TrofeuParaAtribuirDTO(Trofeu trofeu)
 {
     IdTrofeu = trofeu.Id;
     Nome     = trofeu.Nome;
     Pontos   = trofeu.Pontos;
 }