コード例 #1
0
        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);
                });
            }
        }
コード例 #2
0
        public void Insert(FiftyMeterDataEntry entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException("entry");
            }

            entry.SpeciesCode = entry.SpeciesCode.ToUpper();
            List <PointCountBeyond50> beyond50 = entry.GetListBeyond50();
            List <PointCountWithin50> within50 = entry.GetListWithin50();

            beyond50.FindAll(y => !y.MarkForDeletion).ForEach(x =>
            {
                ObservationMapper.Insert(x);
                _state.PointSurvey.Observations.Add(x);
            });
            within50.FindAll(y => !y.MarkForDeletion).ForEach(x =>
            {
                ObservationMapper.Insert(x);
                _state.PointSurvey.Observations.Add(x);
            });
        }
コード例 #3
0
        public void Delete(FiftyMeterDataEntry entry)
        {
            if (entry == null)
            {
                throw new ArgumentNullException("entry");
            }

            ObservationMapper.DeleteTopX(entry.PointSurveyId, PointCountWithin50.ObservationTypeGuid,
                                         entry.SpeciesCode, entry.CountWithin50);
            ObservationMapper.DeleteTopX(entry.PointSurveyId, PointCountBeyond50.ObservationTypeGuid,
                                         entry.SpeciesCode, entry.CountBeyond50);

            entry.GetListBeyond50().ForEach(x =>
            {
                _state.PointSurvey.Observations.RemoveAll(y => y.ObservationTypeId.Equals(x.ObservationTypeId) &&
                                                          y.SpeciesCode.Equals(x.SpeciesCode));
            });
            entry.GetListWithin50().ForEach(x =>
            {
                _state.PointSurvey.Observations.RemoveAll(y => y.ObservationTypeId.Equals(x.ObservationTypeId) &&
                                                          y.SpeciesCode.Equals(x.SpeciesCode));
            });
        }