public SimulacaoAluguelDTO Simular(SimularAlugueisDTO Aluguel) { Carros Carro = this._carrosRepositorio.GetById(Aluguel.CarroId); if (Carro == null) { throw new Exception($"Carro com id: {Aluguel.CarroId} não encontrado."); } Alugueis AluguelSimulacao = new Alugueis { Carro = Carro, Cliente = null, DataAluguel = DateTime.Now, DataCheckin = Aluguel.DataCheckin, DataCheckout = Aluguel.DataCheckout, Origem = Aluguel.Origem, PrecoNoDia = Carro.ValorHora }; return(new SimulacaoAluguelDTO { Carro = Carro, DateCheckin = AluguelSimulacao.DataCheckin, DateCheckout = AluguelSimulacao.DataCheckout, Horas = AluguelSimulacao.Horas, PrecoTotal = AluguelSimulacao.PrecoTotal }); }
public IActionResult SimularAluguel(SimularAlugueisDTO Aluguel) { try { SimulacaoAluguelDTO Retorno = this._alugueisBLL.Simular(Aluguel); return(Ok(new SaidaAPI { ExecutadoComSucesso = true, Data = Retorno })); } catch (Exception e) { return(BadRequest(new SaidaAPI { ExecutadoComSucesso = false, Mensagem = e.Message })); } }