コード例 #1
0
        public CheckListDevolucao Devolver(CheckListDevolucao devolucao)
        {
            Veiculo veiculoAluguel = _veiculoRepository.Obter(devolucao.IdVeiculo);

            if (veiculoAluguel == null)
            {
                devolucao.AddNotification(nameof(devolucao.IdVeiculo), $"Veículo [ID:{devolucao.IdVeiculo}] informado para devolução não existe.");
                return(devolucao);
            }

            Aluguel aluguel = _aluguelRepository.Obter(devolucao.IdAluguel);

            if (aluguel == null)
            {
                devolucao.AddNotification(nameof(devolucao.IdAluguel), $"Aluguel [ID:{devolucao.IdAluguel}] informado para devolução não existe.");
                return(devolucao);
            }

            if (devolucao.Valid)
            {
                devolucao.IdCheckListDevolucao = _checkListDevolucaoRepository.Inserir(devolucao);
                _veiculoRepository.AtualizarDisponibilidade(devolucao.IdVeiculo, false);
            }

            return(devolucao);
        }
コード例 #2
0
        public IActionResult Get(int id)
        {
            try
            {
                Aluguel aluguel = _aluguelRepositorio.Obter(id);

                if (aluguel == null)
                {
                    return(NotFound(Constantes.Mensagens.AluguelNaoEncontrado));
                }

                return(Ok(_mapper.Map <Aluguel, AluguelModel>(aluguel)));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, Constantes.Mensagens.ServicoIndisponivel));
            }
        }
コード例 #3
0
        public ActionResult <dynamic> Get(int idAluguel)
        {
            try
            {
                var aluguel = _aluguelRepositorio.Obter(idAluguel);

                if (aluguel != null)
                {
                    MemoryStream vFileStream = GeradorArquivos.GerarContratoAluguel(_mapper.Map <Aluguel, AluguelModel>(aluguel));
                    return(File(vFileStream, "application/pdf", $"ContratoAluguel_{aluguel.IdAluguel}.pdf"));
                }
                else
                {
                    return(NotFound(Constantes.Mensagens.AluguelNaoEncontrado));
                }
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, Constantes.Mensagens.ServicoIndisponivel));
            }
        }