Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("DepartmentID,DepartmentName,Description")] DepartmentModel departmentModel)
        {
            if (id != departmentModel.DepartmentID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _tempContext.Update(departmentModel);
                    await _tempContext.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DepartmentModelExists(departmentModel.DepartmentID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(departmentModel));
        }
Exemple #2
0
        public async Task <IActionResult> Edit(int id, [Bind("EmployeeID,Name,Surname,Address,Qualification,Contact,DepartmentName")] EmployeeModel employeeModel)
        {
            if (id != employeeModel.EmployeeID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _tempContext.Update(employeeModel);
                    await _tempContext.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeModelExists(employeeModel.EmployeeID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(employeeModel));
        }