public IActionResult Edit(int id, [Bind("Id,VehicleId,CitizenId")] OwnerShip ownerShip)
        {
            if (id != ownerShip.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ownerShip);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OwnerShipExists(ownerShip.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CitizenId"] = new SelectList(_context.Citizen, "Id", "Id", ownerShip.CitizenId);
            ViewData["VehicleId"] = new SelectList(_context.Vehicle, "Id", "Id", ownerShip.VehicleId);
            return(View(ownerShip));
        }
Esempio n. 2
0
        public IActionResult Edit(int id, [Bind("Id,RegistrationNumber,RegisteredDate")] Vehicle vehicle)
        {
            if (id != vehicle.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(vehicle);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VehicleExists(vehicle.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(vehicle));
        }
Esempio n. 3
0
        public IActionResult Edit(int id, [Bind("Id,Name,Address")] Citizen citizen)
        {
            if (id != citizen.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(citizen);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CitizenExists(citizen.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(citizen));
        }