public ViewResult HandoverStart(Guid id) //rent id
        {
            Rent             rent       = _rentsRepository.GetRent(id);
            Car              car        = _carsRepository.GetCar(rent.CarId);
            List <CarDamage> carDamages = _carDamagesRepository.GetCarDamages(car.Id).ToList();
            Client           client     = _clientsRepository.GetClient(rent.ClientId);

            Guid[] guids = new Guid[50];
            for (int i = 0; i < guids.Length - 1; i++)
            {
                guids[i] = Guid.NewGuid();
            }
            RentHandoverStartViewModel model = new RentHandoverStartViewModel
            {
                CarId          = car.Id,
                CarReg         = car.RegistrationNumber,
                CarDamages     = carDamages,
                ClientId       = client.Id,
                ClientName     = client.Name,
                RentId         = rent.Id,
                RentingCompany = rent.RentingCompany.ToString(),
                UserMail       = rent.UserMail,
                UserName       = rent.UserName,
                UserPhone      = rent.UserPhone,
                Guids          = guids,
            };

            return(View(model));
        }
 public IActionResult HandoverStart(RentHandoverStartViewModel model)
 {
     if (ModelState.IsValid)
     {
         HandoverDocument document = new HandoverDocument //TODO Dodać podpisy
         {
             CarId          = model.CarId,
             ClientId       = model.ClientId,
             IsTermAccepted = model.IsTermAccepted,
             RentId         = model.RentId,
             StartDate      = model.StartDate,
             StartFireEx    = model.StartFireEx,
             StartFuel      = model.StartFuel,
             StartManual    = model.StartManual,
             StartMilage    = model.StartMilage,
             StartNotes     = model.StartNotes,
             StartRepairSet = model.StartRepairSet,
             StartService   = model.StartService,
             StartSpare     = model.StartSpare,
             StartTriangle  = model.StartSpare,
             Id             = Guid.NewGuid(),
         };
         _handoverDocumentsRepository.Create(document);
         //Dodanie do historii przebiegu
         MilageRecord record = new MilageRecord
         {
             CarId  = model.CarId,
             Date   = model.StartDate.Date,
             Milage = model.StartMilage,
             Id     = Guid.NewGuid()
         };
         _milageRecordsRepository.Add(record);
         //Aktualizacja danych samochodu
         Car car = _carsRepository.GetCar(model.CarId);
         car.Milage      = model.StartMilage;
         car.IsAvailable = false;
         car.IsReserved  = false;
         _carsRepository.Update(car);
         //Aktualizacja danych wynajmu
         Rent rent = _rentsRepository.GetRent(model.RentId);
         rent.IsActive  = true;
         rent.StartDate = model.StartDate.Date;
         _rentsRepository.Update(rent);
         return(RedirectToAction("Details", new { id = model.RentId }));
     }
     //var dataUri = model.SignatureDataUrl;
     //var encodedImage = dataUri.Split(",")[1];
     //var decodedImage = Convert.FromBase64String(encodedImage);
     //System.IO.File.WriteAllBytes("signature.png", decodedImage);
     return(RedirectToAction("HandoverStart", new { id = model.RentId }));
 }