private void InsertEvents(IEnumerable <WorkoutEvent> filteredEvents)
 {
     foreach (var currentEvent in filteredEvents)
     {
         WorkoutEventManager.Insert(currentEvent);
     }
 }
        private List <WorkoutEvent> FilterEvents(IEnumerable <WorkoutEvent> importedEvents, int personId)
        {
            var cleansedEvents = new List <WorkoutEvent>();

            foreach (var currentEvent in importedEvents)
            {
                var newEvent = new WorkoutEvent
                {
                    Type     = new ActivityType(1, "Running"),
                    Unit     = new UnitOfMeasurement(1, "mi"),
                    User     = MembershipProvider.ReadAll().FirstOrDefault(u => u.Id == personId),
                    Date     = currentEvent.Date.Date,
                    Distance = currentEvent.Distance,
                    Duration = currentEvent.Duration
                };

                if (currentEvent.Title.ToLower() != "richardson running" && currentEvent.Title.ToLower() != "dallas running")
                {
                    newEvent.Title = currentEvent.Title;
                }

                //Only add if there's not a similar activity on the same day
                var matchingEventExists = WorkoutEventManager.ReadAll().Any(
                    e =>
                    e.User.Id == newEvent.User.Id &&
                    e.Date.Date == newEvent.Date.Date &&
                    e.Distance <newEvent.Distance + 1 &&
                                e.Distance> newEvent.Distance - 1);

                if (!matchingEventExists)
                {
                    cleansedEvents.Add(newEvent);
                }
            }

            return(cleansedEvents);
        }