コード例 #1
0
        // GET: CarRent/Edit/5
        public ActionResult Edit(int id)
        {
            var             carRent = carRentRepository.GetCarRentById(id);
            CarRentRegister model   = new CarRentRegister();

            model.InjectFrom(carRent);
            return(View(model));
        }
コード例 #2
0
        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)));
        }
コード例 #3
0
 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));
 }
コード例 #4
0
        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));
        }