コード例 #1
0
		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;
		}
コード例 #2
0
		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);
		}
コード例 #3
0
		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;
		}
コード例 #4
0
		public Employee UpdateEmployee(Employee employee)
		{
			return _employeeRepository.UpdateEmployee(employee);
		}
コード例 #5
0
		public Employee AddEmployee(Employee employee)
		{
			return _employeeRepository.AddEmployee(employee);
		}
コード例 #6
0
		public Employee UpdateEmployee(Employee employee)
		{
			throw new NotImplementedException();
		}