public async Task <IActionResult> Edit(string id, [Bind("VehRegisterNumber,VehLicenceNumber,VehIdentificationNumber,VehMake,RegisteringAuthority,DateOfExpiry,OwnerId")] VehicleLicence vehicleLicence)
        {
            if (id != vehicleLicence.VehRegisterNumber)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(vehicleLicence);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VehicleLicenceExists(vehicleLicence.VehRegisterNumber))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(vehicleLicence));
        }
        public async Task <IActionResult> Create(VehicleLicence vehicleLicence)
        {
            if (VehicleLicenceExists(vehicleLicence.VehRegisterNumber))
            {
                ModelState.AddModelError("LicenceNumber", $"Register Number: {vehicleLicence.VehRegisterNumber} already exist");
            }
            var owner = await _context.Owners.FindAsync(vehicleLicence.OwnerId);

            if (owner == null)
            {
                ModelState.AddModelError("OwnerId", "Owner with this ID Number does not exist");
            }
            if (ModelState.IsValid)
            {
                vehicleLicence.Owner = owner;
                _context.Add(vehicleLicence);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vehicleLicence));
        }