static void Main() { /* * Exemplo programa sem interface.... * */ Console.WriteLine("Informe os dados do alguel:"); Console.Write("\nModelo do carro: "); string modelo = Console.ReadLine(); Console.Write("Data retirada (dd/MM/aaaa hh:mm): "); DateTime dtRetirada = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture); Console.Write("Data devolução (dd/MM/aaaa hh:mm): "); DateTime dtDevolucao = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture); Console.Write("Informe o preço por hora: "); double vlrhora = double.Parse(Console.ReadLine()); Console.Write("Informe o preço por dia: "); double vlrdia = double.Parse(Console.ReadLine()); Aluguel aluguel = new Aluguel(dtRetirada, dtDevolucao, new Veiculo(modelo)); AluguelService aluguelService = new AluguelService(vlrhora, vlrdia, new BrasilTaxaService()); aluguelService.ProcessaFatura(aluguel); Console.WriteLine("\nFATURA: "); Console.WriteLine(aluguel.Fatura); }
public AluguelController(IAluguelRepository aluguelRepositorio, IVeiculoRepository veiculoRepository, IMapper mapper, AluguelService aluguelService) { _mapper = mapper; _aluguelService = aluguelService; _aluguelRepositorio = aluguelRepositorio; _veiculoRepository = veiculoRepository; }
static void Main(string[] args) { Console.WriteLine("Digite a nova Nota: "); System.Console.Write("Modelo de Carro: "); string model = Console.ReadLine(); System.Console.Write("Hora Inicial (dd:MM:yyyy hh:mm): "); DateTime start = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture); System.Console.Write("Hora Final (dd:MM:yyyy hh:mm): "); DateTime finish = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture); System.Console.Write("Digite o Preço por Hora: R$"); double pricePerHour = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); System.Console.Write("Digite o Preço por Dia: R$"); double pricePerDay = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Carro carro = new Carro(model); Aluguel aluguel = new Aluguel(start, finish); Nota nota = new Nota(carro, aluguel); AluguelService servico = new AluguelService(pricePerHour, pricePerDay, new BrasilTaxService()); servico.ProcessarNota(nota); Console.WriteLine(nota.ToString()); }
public ActionResult Novo(Aluguel aluguel) { var service = new AluguelService(); var serviceCarro = new CarroController(); var carro = new Carro(); var carroAlugado = service.ListarCarroAlugado(aluguel); carro = (Carro)carroAlugado; carro.IsAlugado = true; serviceCarro.Novo(carro); try { service.Cadastrar(new Aluguel { NomeDoContratante = aluguel.NomeDoContratante, PlacaDoVeiculo = aluguel.PlacaDoVeiculo, IdCarro = carro.Id }); } catch (Exception) { throw; } return(RedirectToAction("Index")); }
static void Main(string[] args) { AluguelCarro aluguelCarro = new AluguelCarro(DateTime.Parse("25/06/2018 10:30"), DateTime.Parse("27/06/2018 11:40"), new Veiculos("Civic")); AluguelService aluguelService = new AluguelService(10, 130, new BrasilTaxasService()); aluguelService.ProcessarFatura(aluguelCarro); Console.WriteLine(aluguelCarro.Fatura); }
public ActionResult Devolver(string data) { var service = new AluguelService(); var serviceCarro = new CarroController(); var aluguelListado = service.ListarAluguel(data); var carro = new Carro(); var aluguel = new Aluguel(); aluguel = (Aluguel)aluguelListado; var carroAlugado = service.ListarCarroAlugado(aluguel); carro = (Carro)carroAlugado; carro.IsAlugado = false; serviceCarro.Novo(carro); service.ExcluirAluguel(data); return(RedirectToAction("Index")); }
public void TesteDevolucao() { //Arrange DateTime dataAluguel = DateTime.Now; DateTime dataDevolucao = DateTime.MaxValue; int idCarro = 1; string userID = "*****@*****.**"; Aluguel teste = new Aluguel() { AluguelID = 1, DataAluguel = dataAluguel, DataDevolucao = dataDevolucao, CarroID = 1, UserId = userID, Finalizado = true }; Carro carro = new Carro() { CarroID = 1 }; var mockCtx = new Mock <IContext>(); mockCtx.Setup(x => x.Alugueis).Returns(new FakeSET <Aluguel> { teste }); var mockdaoAluguel = new Mock <IAluguelDAO>(); var mockdaoCarro = new Mock <ICarroDAO>(); mockdaoCarro.Setup(x => x.FindById(1)).Returns(carro); mockdaoAluguel.Setup(x => x.Add(teste)).Callback(() => mockdaoAluguel.Setup(x => x.ChecarSeEstaAlugado(1)).Returns(false)); var service = new AluguelService(mockdaoAluguel.Object, mockdaoCarro.Object); //ACT service.Reservar(dataAluguel, dataDevolucao, idCarro, userID); var result = mockdaoAluguel.Object.ChecarSeEstaAlugado(1); //ASSERT Assert.AreEqual(false, result); }
public AluguelController() { aluguelService = new AluguelService(); pessoaJuridicaService = new PessoaJuridicaService(); }