public async Task <IActionResult> Edit(int id, [Bind("ID,Name,PilotID")] Role role)
        {
            if (id != role.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(role);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RoleExists(role.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PilotID"] = new SelectList(_context.Pilots, "ID", "FirstName", role.PilotID);
            return(View(role));
        }
Exemple #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,FirstName,LastName,Adress,PhoneNumber,Weight,PostitionID,IsActif")] Pilot pilot)
        {
            if (id != pilot.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pilot);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PilotExists(pilot.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(pilot));
        }