public ActionResult Create(ReservaAluguelViewModel aluguelVM)
        {
            if (ModelState.IsValid)
            {
                aluguelVM.DataAluguel = aluguelVM.DataAluguel.AddHours(aluguelVM.SelectedHoraAluguel);
                aluguelVM.DataDevolucao = aluguelVM.DataDevolucao.AddHours(aluguelVM.SelectedHoraDevolucao);
                Aluguel aluguel = Mapper.Map<ReservaAluguelViewModel, Aluguel>(aluguelVM);

                service.Adicionar(aluguel);
                return RedirectToAction("Index");
            }
            aluguelVM.SelecaoCarros = new SelectList(service.ListarCarrosDisponiveis());
            return View(aluguelVM);
        }
        public ActionResult DatasRetiradaEDevolucao()
        {
            var model = new ReservaAluguelViewModel();
            IEnumerable<TimeSpan> tempos = Util.Tempos();
            List<SelectListItem> lista = new List<SelectListItem>();
            foreach (var t in tempos)
            {
                lista.Add(new SelectListItem { Value = t.Hours.ToString(), Text = String.Format("{0}:{1:D2}", (int)t.TotalHours, t.Minutes, t.Seconds) });
            }

            model.SelecaoHoraAluguel = lista;
            model.SelecaoHoraDevolucao = lista;
            return PartialView("_ReservaAluguel",model);
        }
        public ActionResult Create()
        {
            ReservaAluguelViewModel aluguelVM = new ReservaAluguelViewModel();
            IEnumerable<TimeSpan> tempos = Util.Tempos();
            List<SelectListItem> lista = new List<SelectListItem>();
            foreach (var t in tempos)
            {
                lista.Add(new SelectListItem { Value = t.Hours.ToString(), Text = String.Format("{0}:{1:D2}", (int)t.TotalHours, t.Minutes, t.Seconds) });
            }

            aluguelVM.SelecaoHoraAluguel = lista;
            aluguelVM.SelecaoHoraDevolucao = lista;
            aluguelVM.SelecaoCarros = new SelectList(service.ListarCarrosDisponiveis(), "CarroID", null, aluguelVM.Carro);
            return View(aluguelVM);
        }
 public ActionResult ReservaData(ReservaAluguelViewModel aluguel)
 {
     aluguel.DataAluguel = aluguel.DataAluguel.AddHours(aluguel.SelectedHoraAluguel);
     aluguel.DataDevolucao = aluguel.DataDevolucao.AddHours(aluguel.SelectedHoraDevolucao);
     return RedirectToAction("EscolhaOCarro",aluguel);
 }
 public ActionResult EscolhaOCarro(ReservaAluguelViewModel aluguelVM)
 {
     IEnumerable<Carro> carros = service.ListarCarrosDisponiveis();
     IEnumerable<CarroViewModel> carrosVM = Mapper.Map<IEnumerable<Carro>, IEnumerable<CarroViewModel>>(carros);
     aluguelVM.CarrosDisponiveis = carrosVM;
     return View(aluguelVM);
 }
        public ActionResult Edit(ReservaAluguelViewModel aluguelVM)
        {
            if (ModelState.IsValid)
            {
                Aluguel aluguel = Mapper.Map<ReservaAluguelViewModel, Aluguel>(aluguelVM);
                service.Editar(aluguel);
                return RedirectToAction("Index");
            }

            aluguelVM.SelecaoCarros = new SelectList(service.ListarCarrosDisponiveis());
            return View(aluguelVM);
        }
        public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            try
            {
                Aluguel aluguel = service.Buscar(id);
                ReservaAluguelViewModel aluguelVM = new ReservaAluguelViewModel()
                {
                    SelecaoCarros = new SelectList(service.ListarCarrosDisponiveis())
                };

                return View(aluguelVM);
            }
            catch (BusinessException ex)
            {
                return HttpNotFound(ex.Message);
            }
        }