private DynamoDbMatch ToDynamoDbMatch(Match match)
 {
     return new DynamoDbMatch()
     {
         EmployeeOneGuid = match.EmployeeOne.Id,
         EmployeeTwoGuid = match.EmployeeTwo.Id
     };
 }
 public Boolean IsAPreexistingMatch(Match match)
 {
     foreach (var preexistingMatch in _preexistingMatches)
     {
         if (preexistingMatch.EmployeeOne.Id == match.EmployeeOne.Id && preexistingMatch.EmployeeTwo.Id == match.EmployeeTwo.Id)
             return true;
         else if (preexistingMatch.EmployeeOne.Id == match.EmployeeTwo.Id && preexistingMatch.EmployeeTwo.Id == match.EmployeeOne.Id)
             return true;
     }
     return false;
 }
Пример #3
0
        public List<Match> MakeMatches(List<Employee> employees, int matchesToMake)
        {
            var matches = new List<Match>();

            var random = new Random();

            //attempt to satisfy matchesToMake until employees are all removed
            for (int i = 0; i < matchesToMake; i++)
            {
                if (employees.Any())
                {
                    //pick first employee
                    var randomIndex = random.Next(0, employees.Count());
                    var firstEmployee = employees[randomIndex];
                    employees.Remove(firstEmployee);

                    //pick second employee
                    var coworkers = employees.Where(e => e.StateWorksIn == firstEmployee.StateWorksIn).ToList();
                    if (coworkers.Any())
                    {
                        randomIndex = random.Next(0, coworkers.Count());
                        var secondEmployee = coworkers[randomIndex];
                        employees.Remove(secondEmployee);

                        var match = new Match()
                        {
                            EmployeeOne = firstEmployee,
                            EmployeeTwo = secondEmployee
                        };

                        if(!this.MatchLogger.IsAPreexistingMatch(match))
                            matches.Add(match);
                    }
                }
            }

            return matches;
        }
 private void AlertMatch(Match match)
 {
     AlertEmployee(match.EmployeeOne, match.EmployeeTwo);
     AlertEmployee(match.EmployeeTwo, match.EmployeeOne);
 }