Exemple #1
0
        public void SaveSurveys(List <BirdSurvey> toSave)
        {
            int newID;

            foreach (BirdSurvey survey in toSave)
            {
                survey.ClimateID = this.GetWeatherIDByDate(survey.SurveyDate);

                SamplePointArea spa = _generalRepo.GetSamplePointAreaByName(survey.SamplePointAreaName);
                survey.SamplePointAreaID = spa.SamplePointAreaID;
                survey.SourceID          = spa.SourceID;

                survey.SurveyorID = _birdRepo.GetSurveyorByName(survey.SurveyorName).SurveyorID;

                newID = _birdRepo.CreateSurvey(survey);

                foreach (BirdSurveyDetails detail in survey.Details)
                {
                    detail.SurveyID  = newID;
                    detail.SpeciesID = _birdRepo.GetSpeciesByName(detail.SpeciesName).SpeciesID;

                    _birdRepo.CreateSurveyDetail(detail);
                }
            }
        }