示例#1
0
        public async Task <IActionResult> Edit(int id,
                                               [Bind("EmployeeId,FirstName,LastName,Salary")] Employee employee)
        {
            if (id != employee.EmployeeId)
            {
                return(NotFound());
            }
            if (ModelState.IsValid)
            {
                try
                {
                    db.Update(employee);
                    await db.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeExists(employee.EmployeeId))
                    {
                        return(NotFound());
                    }
                    throw;
                }

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

            return(View(employee));
        }