private void AddUnitExternalInformation(IdentificationUnit iu, Diversity db)
        {
            var id = db.SingleOrDefault<Identification>("WHERE [CollectionSpecimenID]=@0 AND [IdentificationUnitID]=@1", iu.CollectionSpecimenID, iu.CollectionUnitID);
            if (id != null)
            {
                iu.IdentificationUri = id.NameURI;
                iu.LastIdentificationCache = id.TaxonomicName;
                iu.Qualification = id.IdentificationQualifier;
                iu.AnalysisDate = (id.IdentificationYear.HasValue && id.IdentificationMonth.HasValue && id.IdentificationDay.HasValue)
                    ? new DateTime(id.IdentificationYear.Value, id.IdentificationMonth.Value, id.IdentificationDay.Value, 0, 0, 0)
                    : DateTime.Now;
            }

            iu.Altitude = db.ExecuteScalar<double?>(string.Format("SELECT [dbo].[DiversityMobile_IdentificationUnitAltitude] ( {0} )", iu.CollectionUnitID));
            iu.Latitude = db.ExecuteScalar<double?>(string.Format("SELECT [dbo].[DiversityMobile_IdentificationUnitLatitude] ( {0} )", iu.CollectionUnitID));
            iu.Longitude = db.ExecuteScalar<double?>(string.Format("SELECT [dbo].[DiversityMobile_IdentificationUnitLongitude] ( {0} )", iu.CollectionUnitID));
        }
        private void AddUnitExternalInformation(IdentificationUnit iu, Diversity db)
        {
            var id = db.SingleOrDefault<Identification>("WHERE [CollectionSpecimenID]=@0 AND [IdentificationUnitID]=@1", iu.CollectionSpecimenID, iu.CollectionUnitID);
            if (id != null)
            {
                iu.IdentificationUri = id.NameURI;
                iu.LastIdentificationCache = id.TaxonomicName;
                iu.Qualification = id.IdentificationQualifier;
                iu.AnalysisDate = (id.IdentificationYear.HasValue && id.IdentificationMonth.HasValue && id.IdentificationDay.HasValue)
                    ? new DateTime(id.IdentificationYear.Value, id.IdentificationMonth.Value, id.IdentificationDay.Value, 0, 0, 0)
                    : DateTime.Now;
            }

            AddLocalization(iu, db);
        }
 private void AddLocalization(Event ev, Diversity db)
 {
     // The decimal -> double dance ensures the coordinates round trip correctly
     ev.Altitude = DecimalToDouble(db.SingleOrDefault<decimal?>("SELECT CAST([AverageAltitudeCache] AS DECIMAL(25, 20)) FROM [CollectionEventLocalisation] WHERE [CollectionEventID]=@0 AND [LocalisationSystemID]=@1", ev.CollectionEventID, ClientServiceConversions.ALTITUDE_LOC_SYS_ID));
     var lat = db.SingleOrDefault<decimal?>("SELECT CAST([AverageLatitudeCache] AS DECIMAL(25, 20)) FROM [CollectionEventLocalisation] WHERE [CollectionEventID]=@0 AND [LocalisationSystemID]=@1", ev.CollectionEventID, ClientServiceConversions.WGS84_LOC_SYS_ID);
     ev.Latitude = DecimalToDouble(lat);
     var lon = db.SingleOrDefault<decimal?>("SELECT CAST([AverageLongitudeCache] AS DECIMAL(25, 20)) FROM [CollectionEventLocalisation] WHERE [CollectionEventID]=@0 AND [LocalisationSystemID]=@1", ev.CollectionEventID, ClientServiceConversions.WGS84_LOC_SYS_ID);
     ev.Longitude = DecimalToDouble(lon);
 }
 private void AddLocalization(IdentificationUnit iu, Diversity db)
 {
     // The decimal -> double dance ensures the coordinates round trip correctly
     iu.Altitude = DecimalToDouble(db.SingleOrDefault<decimal?>("SELECT CAST([Geography].Z AS DECIMAL(25, 20)) FROM [IdentificationUnitGeoAnalysis] WHERE [CollectionSpecimenID]=@0 AND [IdentificationUnitID]=@1", iu.CollectionSpecimenID, iu.CollectionUnitID));
     var lat = db.SingleOrDefault<decimal?>("SELECT CAST([Geography].Lat AS DECIMAL(25, 20)) FROM [IdentificationUnitGeoAnalysis] WHERE [CollectionSpecimenID]=@0 AND [IdentificationUnitID]=@1", iu.CollectionSpecimenID, iu.CollectionUnitID);
     iu.Latitude = DecimalToDouble(lat);
     var lon = db.SingleOrDefault<decimal?>("SELECT CAST([Geography].Long AS DECIMAL(25, 20)) FROM [IdentificationUnitGeoAnalysis] WHERE [CollectionSpecimenID]=@0 AND [IdentificationUnitID]=@1", iu.CollectionSpecimenID, iu.CollectionUnitID);
     iu.Longitude = DecimalToDouble(lon);
 }