Ejemplo n.º 1
0
        public IList <MatchingPair> GetMatchingPairs(ICollection <LostAndFoundIndexedItem> items)
        {
            var findings   = items.Where(item => item.ItemType == LostAndFoundIndexedItem.Type.Finding).ToArray();
            var randomizer = new Random();

            Func <LostAndFoundIndexedItem, LostAndFoundIndexedItem> randomNonMatch =
                item => findings[randomizer.Next(0, findings.Length - 1)];

            var unmatched = items.Where(match => match.ItemType == LostAndFoundIndexedItem.Type.Loss &&
                                        match.MatchedRecordID == null &&
                                        (DateTime.Now - match.DateOfIncident).Days > _daysWithoutMatch);

            return(unmatched.Select(item => _mapper.MapNonMatch(item, randomNonMatch(item))).ToList());
        }