Exemple #1
0
        public List <List <string> > ValidateImportList(List <BirdSurvey> toSave)
        {
            List <string>         SPAErrors      = new List <string>();
            List <string>         SurveyorErrors = new List <string>();
            List <string>         SpeciesErrors  = new List <string>();
            List <string>         ClimateErrors  = new List <string>();
            List <List <string> > validations    = new List <List <string> >();

            foreach (BirdSurvey survey in toSave)
            {
                if (_generalRepo.GetSamplePointAreaByName(survey.SamplePointAreaName) == null)
                {
                    SPAErrors.Add(survey.SamplePointAreaName);
                }


                survey.ClimateID = this.GetWeatherIDByDate(survey.SurveyDate);

                if (_birdRepo.GetSurveyorByName(survey.SurveyorName) == null)
                {
                    SurveyorErrors.Add(survey.SurveyorName);
                }

                foreach (BirdSurveyDetails detail in survey.Details)
                {
                    if (_birdRepo.GetSpeciesByName(detail.SpeciesName) == null)
                    {
                        SpeciesErrors.Add(detail.SpeciesName);
                    }
                }
            }
            validations.Add(SPAErrors.Distinct().ToList());
            validations.Add(SurveyorErrors.Distinct().ToList());
            validations.Add(ClimateErrors.Distinct().ToList());
            validations.Add(SpeciesErrors.Distinct().ToList());

            return(validations);
        }