Exemple #1
0
        public IActionResult Put([FromBody] AluguelModel aluguel)
        {
            try
            {
                Aluguel aluguelRequisicaoPut = _mapper.Map <AluguelModel, Aluguel>(aluguel);

                if (aluguelRequisicaoPut.Invalid)
                {
                    return(StatusCode(StatusCodes.Status400BadRequest, new ErrorModel(aluguelRequisicaoPut.Notifications)));
                }

                var aluguelExistente = _aluguelRepositorio.Obter(aluguelRequisicaoPut.IdAluguel);

                if (aluguelExistente != null)
                {
                    _aluguelRepositorio.Atualizar(aluguelRequisicaoPut);
                }
                else
                {
                    return(StatusCode(StatusCodes.Status404NotFound, Constantes.Mensagens.AluguelNaoEncontrado));
                }

                return(Ok());
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, Constantes.Mensagens.ServicoIndisponivel)); throw;
            }
        }