Exemplo n.º 1
0
        public void t_PointCountLess50_Delete()
        {
            Observation_ado setupObject = null;

            // backdoor data setup
            DbTestHelper.LoadAdoObjects(delegate(IbaUnitTestEntities iba)
            {
                setupObject = new Observation_ado()
                {
                    Comments          = "asdfasdf asdf adsfa dsfads fasdf adsfasd fadsf awefr34fr34r34 ",
                    SpeciesId         = new Guid(TestHelper.SPECIES_1_ID),
                    EventId           = TestHelper.TestGuid1,
                    ObservationTypeId = _PointCountLess50TypeId
                };
                iba.AddToObservation_ado(setupObject);
            });
            List <Observation_ado> Observationlist = DbTestHelper.LoadExtraneousObservations(TestHelper.TestGuid3);

            ObservationMapper.Delete(new PointCountWithin50()
            {
                Id = setupObject.ObservationId
            });

            // Validate results
            using (IbaUnitTestEntities iba = new IbaUnitTestEntities())
            {
                var PointCountLess50Query = from PointCountLess50s in iba.Observation_ado
                                            select PointCountLess50s;
                Assert.IsNotNull(PointCountLess50Query, "Query result is null");
                Assert.AreEqual(Observationlist.Count(), PointCountLess50Query.Count(), "Wrong number of results in query");
                validateExtraObservations(Observationlist, PointCountLess50Query);
            }
        }
        public void Update(FiftyMeterDataEntry entry)
        {
            entry.SpeciesCode = entry.SpeciesCode.ToUpper();
            List <PointCountBeyond50> beyond50 = entry.GetListBeyond50();
            List <PointCountWithin50> within50 = entry.GetListWithin50();

            beyond50.FindAll(y => y.Id.Equals(0)).ForEach(x =>
            {
                ObservationMapper.Update(x);
                _state.PointSurvey.Observations.Add(x);
            });
            within50.FindAll(y => y.Id.Equals(0)).ForEach(x =>
            {
                ObservationMapper.Update(x);
                _state.PointSurvey.Observations.Add(x);
            });



            int deleteBeyond = _state.PointSurvey.Observations.OfType <PointCountBeyond50>().Where(x => x.SpeciesCode.Equals(entry.SpeciesCode)).Count() - beyond50.Count();
            int deleteWithin = _state.PointSurvey.Observations.OfType <PointCountWithin50>().Where(x => x.SpeciesCode.Equals(entry.SpeciesCode)).Count() - within50.Count();

            if (deleteBeyond > 0)
            {
                var toDelete = _state.PointSurvey.Observations.Where(x => x.SpeciesCode.Equals(entry.SpeciesCode)).Take(deleteBeyond);
                toDelete.ToList().ForEach(x =>
                {
                    ObservationMapper.Delete(x);
                    _state.PointSurvey.Observations.Remove(x);
                });
            }
            if (deleteWithin > 0)
            {
                var toDelete = _state.PointSurvey.Observations.Where(x => x.SpeciesCode.Equals(entry.SpeciesCode)).Take(deleteWithin);
                toDelete.ToList().ForEach(x =>
                {
                    ObservationMapper.Delete(x);
                    _state.PointSurvey.Observations.Remove(x);
                });
            }
        }
Exemplo n.º 3
0
 public void Delete(SupplementalObservation observation)
 {
     ObservationMapper.Delete(observation);
     _state.SiteVisit.SupplementalObservations.RemoveAll(x => x.Id.Equals(observation.Id));
 }