public List <FiftyMeterDataEntry> SelectAllForEvent(Guid eventId)
        {
            List <FiftyMeterDataEntry> dataEntryList = new List <FiftyMeterDataEntry>();

            if (!eventId.Equals(Guid.Empty))
            {
                List <PointCountBeyond50> beyond50List = null;
                List <PointCountWithin50> less50List   = null;
                if (_state.PointSurvey.Id.Equals(eventId))
                {
                    beyond50List = _state.PointSurvey.Observations.OfType <PointCountBeyond50>().ToList();
                    less50List   = _state.PointSurvey.Observations.OfType <PointCountWithin50>().ToList();
                }
                else
                {
                    FiftyMeterPointSurvey survey = _state.SiteVisit.PointSurveys.Find(x => x.Id.Equals(eventId));
                    if (survey != null)
                    {
                        beyond50List = survey.Observations.OfType <PointCountBeyond50>().ToList();
                        less50List   = survey.Observations.OfType <PointCountWithin50>().ToList();
                    }
                }

                FiftyMeterDataEntryFactory.CreateEntriesFromPointCounts <PointCountBeyond50>(beyond50List, dataEntryList);
                FiftyMeterDataEntryFactory.CreateEntriesFromPointCounts <PointCountWithin50>(less50List, dataEntryList);
            }

            return(dataEntryList);
        }
        public void t_CountByPointSurveyId_Beyond50()
        {
            List <FiftyMeterDataEntry> dataEntryList = new List <FiftyMeterDataEntry>();
            List <PointCountBeyond50>  fiftyList     = new List <PointCountBeyond50>()
            {
                // 2 of species 1 at same point
                new PointCountBeyond50()
                {
                    EventId     = TestHelper.TestGuid1,
                    SpeciesCode = TestHelper.SPECIES_1_CODE
                },
                new PointCountBeyond50()
                {
                    EventId     = TestHelper.TestGuid1,
                    SpeciesCode = TestHelper.SPECIES_1_CODE
                },
                // 1 of species 1 at different point
                new PointCountBeyond50()
                {
                    EventId     = TestHelper.TestGuid2,
                    SpeciesCode = TestHelper.SPECIES_1_CODE
                },
                // 1 of different species at the second point
                new PointCountBeyond50()
                {
                    EventId     = TestHelper.TestGuid2,
                    SpeciesCode = TestHelper.SPECIES_2_CODE
                }
            };

            // Exercise the system under test
            FiftyMeterDataEntryFactory.CreateEntriesFromPointCounts <PointCountBeyond50>(fiftyList, dataEntryList);

            // There should be three entries:
            // 1. Species 1 at point 1 with count 2
            // 2. Species 1 at point 2 with count 1
            // 3. Species 2 at point 2 with count 1
            Assert.AreEqual(3, dataEntryList.Count(), "wrong number of results");
            FiftyMeterDataEntry entry1 = dataEntryList.Single(x => x.PointSurveyId.Equals(TestHelper.TestGuid1) &&
                                                              x.SpeciesCode.Equals(TestHelper.SPECIES_1_CODE));

            Assert.IsNotNull(entry1, "entry 1 missing");
            Assert.AreEqual(2, entry1.CountBeyond50, "entry 1 wrong count");

            FiftyMeterDataEntry entry2 = dataEntryList.Single(x => x.PointSurveyId.Equals(TestHelper.TestGuid2) &&
                                                              x.SpeciesCode.Equals(TestHelper.SPECIES_1_CODE));

            Assert.IsNotNull(entry2, "entry 1 missing");
            Assert.AreEqual(1, entry2.CountBeyond50, "entry 2 wrong count");

            FiftyMeterDataEntry entry3 = dataEntryList.Single(x => x.PointSurveyId.Equals(TestHelper.TestGuid2) &&
                                                              x.SpeciesCode.Equals(TestHelper.SPECIES_2_CODE));

            Assert.IsNotNull(entry3, "entry 1 missing");
            Assert.AreEqual(1, entry3.CountBeyond50, "entry 3 wrong count");
        }
        /// <summary>
        /// Factory method to build and retrieve all observation information for a particular site visit, for use on the review page.
        /// </summary>
        /// <returns></returns>
        public static List <ReviewObservation> GetReviewList(IUserStateManager state, IGlobalMap globalMap)
        {
            // TODO: use of state should be moved to a presenter class
            List <ReviewObservation> reviewList = new List <ReviewObservation>();

            state.SiteVisit.PointSurveys.OrderBy(x => x.StartTimeStamp).ToList().ForEach(x =>
            {
                List <FiftyMeterDataEntry> entryList = new List <FiftyMeterDataEntry>();
                FiftyMeterDataEntryFactory.CreateEntriesFromPointCounts <PointCountBeyond50>(
                    x.Observations.OfType <PointCountBeyond50>().ToList <PointCountBeyond50>(), entryList);
                FiftyMeterDataEntryFactory.CreateEntriesFromPointCounts <PointCountWithin50>(
                    x.Observations.OfType <PointCountWithin50>().ToList <PointCountWithin50>(), entryList);

                entryList.ForEach(y =>
                {
                    reviewList.Add(new ReviewObservation(x, y, state, globalMap));
                });
            });

            return(reviewList.OrderBy(x => x.SamplingPointName).ToList());
        }