Exemplo n.º 1
0
        public List<TrainingVisit> GetLatestTrainings(Employee employee)
        {
            const int recentDays = 10;
            var maxDate = DateTime.Now.AddDays(-recentDays);

            var emploeeTrenings = employee.EmployeeTrainings;

            var recentVisits = emploeeTrenings.SelectMany(training =>
                training.TrainingVisits.Where(trainingVisit => trainingVisit.Date > maxDate));

            return recentVisits.ToList();
        }
Exemplo n.º 2
0
        public void Test_GetLatestTrainings_Have2EmploeesAndOneHasResentDate_FoundOneEmploee()
        {
            // Arrange
            var testEmploee = new Employee
            {
                EmployeeTrainings = new List<EmployeeTraining>()
                {
                    new EmployeeTraining()
                    {
                        TrainingVisits = new List<TrainingVisit>()
                        {
                            new TrainingVisit
                            {
                                Date = DateTime.Now.AddDays(-3),
                            }
                        }
                    },

                    new EmployeeTraining()
                    {
                        TrainingVisits = new List<TrainingVisit>()
                        {
                            new TrainingVisit
                            {
                                Date = DateTime.Now.AddDays(-20),
                            }
                        }
                    },
                }
            };

            var serviceUnderTest = new EmploeeService(null);

            // Act
            var actualVisits = serviceUnderTest.GetLatestTrainings(testEmploee);

            // Assert
            Assert.AreEqual(1, actualVisits.Count);

            const int recentDays = 10;
            var maxDate = DateTime.Now.AddDays(-recentDays);
            Assert.True(actualVisits.First().Date > maxDate);
        }
Exemplo n.º 3
0
 public void Update(Employee employee)
 {
     Context.Entry(employee).State = EntityState.Modified;
 }
Exemplo n.º 4
0
 public void Insert(Employee employee)
 {
     Context.Employees.Add(employee);
 }
Exemplo n.º 5
0
 public void Insert(Employee employee)
 {
     EmployeeRepository.Insert(employee);
     EmployeeRepository.Save();
 }