public Employee UpdateEmployee(Employee employee) { PopulateEmployeesFromCache(); var temp = _employees.Single(x => x.Id == employee.Id); if (temp != null) { temp.FirstName = employee.FirstName; temp.LastName = employee.LastName; temp.Dependents = employee.Dependents; temp.Salary = employee.Salary; } _memoryCache.Set(CacheKey, _employees, _cacheItemPolicy); return temp; }
public void AddEmployeeTest() { //Arrange const int employeeId = 1; var employee = new Employee() { FirstName = "Test", LastName = "User" }; _mockEmployeeRepository.Setup(m => m.AddEmployee(employee)).Returns((Employee e) => { e.Id = employeeId; return e; }); //Act _employeeService.AddEmployee(employee); //Assert Assert.AreEqual(employeeId, employee.Id); //_mockUnitWork.Verify(m => m.Commit(), Times.Once); }
public Employee AddEmployee(Employee employee) { PopulateEmployeesFromCache(); var lastEmployeeId = 0; var lastEmployee = _employees.OrderByDescending(x => x.Id).FirstOrDefault(); if (lastEmployee != null) lastEmployeeId = lastEmployee.Id; employee.Id = ++lastEmployeeId; //var temp = _employees.FirstOrDefault(x => x.Id == employee.Id); //if (temp == null) _employees.Add(employee); _memoryCache.Set(CacheKey, _employees, _cacheItemPolicy); return employee; }
public Employee UpdateEmployee(Employee employee) { return _employeeRepository.UpdateEmployee(employee); }
public Employee AddEmployee(Employee employee) { return _employeeRepository.AddEmployee(employee); }
public Employee UpdateEmployee(Employee employee) { throw new NotImplementedException(); }