// GET: CarRent/Edit/5
        public ActionResult Edit(int id)
        {
            var             carRent = carRentRepository.GetCarRentById(id);
            CarRentRegister model   = new CarRentRegister();

            model.InjectFrom(carRent);
            return(View(model));
        }
        public ActionResult Delete(int id, CarRentRegister model)
        {
            CarRentRegister carRentToDelete = new CarRentRegister();

            carRentToDelete = carRentRepository.GetCarRentById(id);
            model.InjectFrom(carRentToDelete);
            carRentRepository.DeleteCarRent(carRentToDelete);
            return(RedirectToAction(nameof(Index)));
        }
 public ActionResult Edit(int id, CarRentRegister model)
 {
     if (ModelState.IsValid)
     {
         CarRentRegister carRentRegister = new CarRentRegister();
         carRentRegister.InjectFrom(model);
         var customerToUpdate = carRentRepository.UpdateCarRent(carRentRegister);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(model));
 }
        public ActionResult Create(CarRentModel model)
        {
            if (ModelState.IsValid)
            {
                DateTime startDate = model.StartDate;
                DateTime endDate   = model.EndDate;


                if (startDate > endDate)
                {
                    return(RedirectToAction(nameof(Create)));
                }
                else
                {
                    CarRentRegister carRentRegister = new CarRentRegister();
                    carRentRegister.InjectFrom(model);
                    var createCarRegister = carRentRepository.AddCarRent(carRentRegister);
                    return(RedirectToAction(nameof(Index)));
                }
            }

            return(View(model));
        }