/// <summary>
 /// Create a TaxonCountyOccurrence instance.
 /// </summary>
 /// <param name='taxon'>Taxon.</param>
 /// <param name='countyId'>County id.</param>
 /// <param name='countyOccurrence'>County occurrence.</param>
 /// <param name='hasSourceId'>Indicates if sourceId has a value.</param>
 /// <param name='sourceId'>Source id.</param>
 /// <param name='source'>Source.</param>
 /// <param name='hasArtDataId'>Indicates if artDataId has a value.</param>
 /// <param name='artDataId'>Art data id.</param>
 /// <param name='originalCountyOccurrence'>Original county occurrence.</param>
 public TaxonCountyOccurrence(Taxon taxon,
                              Int32 countyId,
                              String countyOccurrence,
                              Boolean hasSourceId,
                              Int32 sourceId,
                              String source,
                              Boolean hasArtDataId,
                              Int32 artDataId,
                              String originalCountyOccurrence)
 {
     _taxon            = taxon;
     _county           = GeographicManager.GetCounty(countyId);
     _countyOccurrence = countyOccurrence;
     _hasSourceId      = hasSourceId;
     if (_hasSourceId)
     {
         _sourceId = sourceId;
     }
     else
     {
         _sourceId = DEFAULT_SOURCE_ID;
     }
     _source       = source;
     _hasArtDataId = hasArtDataId;
     if (_hasArtDataId)
     {
         _artDataId = artDataId;
     }
     else
     {
         _artDataId = DEFAULT_ART_DATA_ID;
     }
     _originalCountyOccurrence = originalCountyOccurrence;
 }
 /// <summary>
 /// Create a TaxonCountyOccurrence instance.
 /// </summary>
 /// <param name='taxon'>Taxon.</param>
 /// <param name='countyIdentifier'>County identifier.</param>
 /// <param name='countyOccurrence'>County occurrence.</param>
 /// <param name='originalCountyOccurrence'>Original county occurrence.</param>
 public TaxonCountyOccurrence(Taxon taxon,
                              String countyIdentifier,
                              String countyOccurrence,
                              String originalCountyOccurrence)
 {
     _taxon                    = taxon;
     _county                   = GeographicManager.GetCounty(countyIdentifier);
     _countyOccurrence         = countyOccurrence;
     _hasSourceId              = false;
     _sourceId                 = DEFAULT_SOURCE_ID;
     _source                   = null;
     _hasArtDataId             = false;
     _artDataId                = DEFAULT_ART_DATA_ID;
     _originalCountyOccurrence = originalCountyOccurrence;
 }
        /// <summary>
        /// Convert a SpeciesObservationSearchCriteria to a
        /// WebSpeciesObservationSearchCriteria.
        /// </summary>
        /// <param name="searchCriteria">The SpeciesObservationSearchCriteria.</param>
        /// <returns>The WebSpeciesObservationSearchCriteria.</returns>
        private static WebSpeciesObservationSearchCriteria GetSpeciesObservationSearchCriteria(SpeciesObservationSearchCriteria searchCriteria)
        {
            WebDataField dataField;
            WebSpeciesObservationSearchCriteria webSearchCriteria;

            webSearchCriteria = new WebSpeciesObservationSearchCriteria();
            webSearchCriteria.IsAccuracySpecified = searchCriteria.HasAccuracy;
#if DATA_SPECIFIED_EXISTS
            webSearchCriteria.IsAccuracySpecifiedSpecified = true;
#endif
            if (webSearchCriteria.IsAccuracySpecified)
            {
                webSearchCriteria.Accuracy = searchCriteria.Accuracy;
#if DATA_SPECIFIED_EXISTS
                webSearchCriteria.AccuracySpecified = true;
#endif
            }

            webSearchCriteria.IsBirdNestActivityLevelSpecified = searchCriteria.HasBirdNestActivityLevel;
#if DATA_SPECIFIED_EXISTS
            webSearchCriteria.IsBirdNestActivityLevelSpecifiedSpecified = true;
#endif
            if (webSearchCriteria.IsBirdNestActivityLevelSpecified)
            {
                webSearchCriteria.BirdNestActivityLevel = searchCriteria.BirdNestActivityLevel;
#if DATA_SPECIFIED_EXISTS
                webSearchCriteria.BirdNestActivityLevelSpecified = true;
#endif
            }

            webSearchCriteria.Counties = GeographicManager.GetCounties(searchCriteria.Counties);

            webSearchCriteria.DatabaseIds = null;
            if (searchCriteria.DatabaseIds.IsNotEmpty())
            {
                webSearchCriteria.DatabaseIds = searchCriteria.DatabaseIds;
            }

            webSearchCriteria.IncludeNeverFoundObservations = searchCriteria.IncludeNeverFoundObservations;
#if DATA_SPECIFIED_EXISTS
            webSearchCriteria.IncludeNeverFoundObservationsSpecified = true;
#endif
            webSearchCriteria.IncludeNotRediscoveredObservations = searchCriteria.IncludeNotRediscoveredObservations;
#if DATA_SPECIFIED_EXISTS
            webSearchCriteria.IncludeNotRediscoveredObservationsSpecified = true;
#endif
            webSearchCriteria.IncludePositiveObservations = searchCriteria.IncludePositiveObservations;
#if DATA_SPECIFIED_EXISTS
            webSearchCriteria.IncludePositiveObservationsSpecified = true;
#endif

            if (webSearchCriteria.DataFields.IsNull())
            {
                webSearchCriteria.DataFields = new List <WebDataField>();
            }

            dataField       = new WebDataField();
            dataField.Name  = "IncludeUncertainTaxonDetermination";
            dataField.Type  = WebDataType.Boolean;
            dataField.Value = searchCriteria.IncludeUncertainTaxonDetermination.WebToString();
            webSearchCriteria.DataFields.Add(dataField);

            webSearchCriteria.LocationSearchString = searchCriteria.LocalitySearchString;

            webSearchCriteria.IsRectangleSpecified = searchCriteria.HasBoundingBox;
#if DATA_SPECIFIED_EXISTS
            webSearchCriteria.IsRectangleSpecifiedSpecified = true;
#endif
            if (webSearchCriteria.IsRectangleSpecified)
            {
                webSearchCriteria.EastCoordinate  = searchCriteria.MaxEastCoordinate;
                webSearchCriteria.NorthCoordinate = searchCriteria.MaxNorthCoordinate;
                webSearchCriteria.WestCoordinate  = searchCriteria.MaxWestCoordinate;
                webSearchCriteria.SouthCoordinate = searchCriteria.MaxSouthCoordinate;
#if DATA_SPECIFIED_EXISTS
                webSearchCriteria.EastCoordinateSpecified = true;
#endif
#if DATA_SPECIFIED_EXISTS
                webSearchCriteria.NorthCoordinateSpecified = true;
#endif
#if DATA_SPECIFIED_EXISTS
                webSearchCriteria.WestCoordinateSpecified = true;
#endif
#if DATA_SPECIFIED_EXISTS
                webSearchCriteria.SouthCoordinateSpecified = true;
#endif
            }

            webSearchCriteria.ObservationEndDate = searchCriteria.ObservationEndDate;
#if DATA_SPECIFIED_EXISTS
            webSearchCriteria.ObservationEndDateSpecified = true;
#endif
            webSearchCriteria.ObservationStartDate = searchCriteria.ObservationStartDate;
#if DATA_SPECIFIED_EXISTS
            webSearchCriteria.ObservationStartDateSpecified = true;
#endif
            webSearchCriteria.ObserverSearchString = searchCriteria.ObserverSearchString;
            webSearchCriteria.UseOfObservationDate = searchCriteria.UseOfObservationDate;
#if DATA_SPECIFIED_EXISTS
            webSearchCriteria.UseOfObservationDateSpecified = true;
#endif

            webSearchCriteria.RegistrationEndDate = searchCriteria.RegistrationEndDate;
#if DATA_SPECIFIED_EXISTS
            webSearchCriteria.RegistrationEndDateSpecified = true;
#endif
            webSearchCriteria.RegistrationStartDate = searchCriteria.RegistrationStartDate;
#if DATA_SPECIFIED_EXISTS
            webSearchCriteria.RegistrationStartDateSpecified = true;
#endif
            webSearchCriteria.UseOfRegistrationDate = searchCriteria.UseOfRegistrationDate;
#if DATA_SPECIFIED_EXISTS
            webSearchCriteria.UseOfRegistrationDateSpecified = true;
#endif

            webSearchCriteria.Provinces = GeographicManager.GetProvinces(searchCriteria.Provinces);

            webSearchCriteria.TaxonIds = null;
            if (searchCriteria.TaxonIds.IsNotEmpty())
            {
                webSearchCriteria.TaxonIds = searchCriteria.TaxonIds;
            }

            webSearchCriteria.UserRoleId = searchCriteria.UserRoleId;
#if DATA_SPECIFIED_EXISTS
            webSearchCriteria.UserRoleIdSpecified = true;
#endif

            return(webSearchCriteria);
        }