예제 #1
0
        public NotificationResult Atualizar(Jogador entidade)
        {
            var NotificationResult = new NotificationResult();

            try
            {
                if (entidade.CodJogador != 0)
                {
                    entidade.CodJogador = entidade.CodJogador;
                }

                if (NotificationResult.IsValid)
                {
                    _jogadorRepositorio.Atualizar(entidade);
                    NotificationResult.Add("Cadastro Alterado com Sucesso!");

                    return(NotificationResult);
                }

                else
                {
                    return(NotificationResult.Add(new NotificationError("O codigo informado não existe!", NotificationErrorType.USER)));
                }
            }
            catch (Exception)
            {
                return(NotificationResult.Add(new NotificationError("O codigo informado não existe!", NotificationErrorType.USER)));
            }
        }
예제 #2
0
 public IActionResult Post([FromBody] Jogador jogador)
 {
     try
     {
         jogador.Validar();
         if (!jogador.Valido)
         {
             return(BadRequest(jogador.ObterMensagensValidacao()));
         }
         if (jogador.Id > 0)
         {
             _jogadorRepositorio.Atualizar(jogador);
         }
         else
         {
             _jogadorRepositorio.Adicionar(jogador);
         }
         return(Created("api/jogador", jogador));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.ToString()));
     }
 }