public async Task <IActionResult> Edit(int id, [Bind("id,Age,BusinessTravel,Department,DistanceFromHome,EducationField,EmployeeNumber,Gender,JobRole,MaritalStatus,NumCompaniesWorked,OverTime,TotalWorkingYears,TrainingTimesLastYear,YearsAtCompany,YearsInCurrentRole,YearsSinceLastPromotion,YearsWithCurrManager")] HumanResource humanResource) { if (id != humanResource.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(humanResource); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HumanResourceExists(humanResource.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(humanResource)); }
public long UpdateEmployee(long id, UpdateEmployeeRequest updateEmployee) { var employee = context.Employees.FirstOrDefault(x => x.Id == id); if (employee == null) { return(-1); } employee.Name = updateEmployee.Name; employee.LastUpdate = DateTime.Now; context.Update(employee); context.SaveChanges(); return(employee.Id); }