private static Employee GetEmployeeById(SoftUniEntities entity, int employeeId) { var employeeById = entity.Employees.FirstOrDefault(e => e.EmployeeID == employeeId); return employeeById; }
// Problem 6 public static void UpdateTwoEmployeesSimulteniously( int firstEmployeeId, decimal firstSalary, int secondEmployeeId, decimal secondSalary) { var firstEmployee = GetEmployeeById(SoftUniContext, firstEmployeeId); firstEmployee.Salary = firstSalary; var softUniContext2 = new SoftUniEntities(); var secondEmployee = GetEmployeeById(softUniContext2, secondEmployeeId); secondEmployee.Salary = secondSalary; SoftUniContext.SaveChanges(); softUniContext2.SaveChanges(); }