public ViewResult AddRent()
        {
            RentAddRentViewModel model = new RentAddRentViewModel();

            model.Cars    = _carsRepository.GetFreeCars().ToList();
            model.Clients = _clientsRepository.GetAllClients().ToList();
            return(View(model));
        }
 public IActionResult AddRent(RentAddRentViewModel model)
 {
     if (ModelState.IsValid)
     {
         Rent rent = new Rent
         {
             CarId                  = model.CarId,
             ClientId               = model.ClientId,
             StartDate              = model.ProposedStartDate,
             EndDate                = model.EndDate,
             RentFee                = model.RentFee,
             DamageFee              = model.DamageFee,
             MilageLimit            = model.MilageLimit,
             OverMilageFee          = model.OverMilageFee,
             TyresIncluded          = model.TyresIncluded,
             ServiceIncluded        = model.ServiceIncluded,
             AssistanceIncluded     = model.AssistanceIncluded,
             ReplacementCarIncluded = model.ReplacementCarIncluded,
             IsEndDateSet           = model.IsEndDateSet,
             InitialPayment         = model.InitialPayment,
             UserName               = model.UserName,
             UserMail               = model.UserMail,
             UserPhone              = model.UserPhone,
             RentingCompany         = model.RentingCompany,
             RentType               = model.RentType,
             IsFinished             = false,
             IsActive               = false,
             Id = Guid.NewGuid()
         };
         Car car = _carsRepository.GetCar(model.CarId);
         car.IsReserved    = true;
         car.ReservedUntil = model.ProposedStartDate.Date;
         _carsRepository.Update(car);
         _rentsRepository.Add(rent);
         return(RedirectToAction("Reservations"));
     }
     return(RedirectToAction("AddRent"));
 }