public int InsertEvent(Event ev, IEnumerable<EventProperty> properties, UserCredentials login) { using (var db = login.GetConnection()) using (var t = new Transaction(db)) { db.Insert(ev); var geoString = SerializeLocalization(ev.Latitude, ev.Longitude, ev.Altitude); foreach (var loc in ev.GetLocalisations(login)) { db.Insert(loc); if (!string.IsNullOrWhiteSpace(geoString)) { db.Execute("UPDATE [dbo].[CollectionEventLocalisation] SET geography=GEOGRAPHY::STGeomFromText(@0, 4326) WHERE CollectionEventID=@1 AND LocalisationSystemID=@2", geoString, loc.CollectionEventID, loc.LocalisationSystemID); } } if (properties != null) foreach (var p in properties) { p.CollectionEventID = ev.CollectionEventID; db.Insert(p); } t.Complete(); return ev.CollectionEventID; } }
public int InsertSpecimen(Specimen s, UserCredentials login) { using (var db = login.GetConnection()) using (var t = new Transaction(db)) { db.Insert(s); db.Insert(s.GetProject(login.ProjectID)); db.Insert(s.GetAgent(login)); t.Complete(); return s.CollectionSpecimenID; } }
public int InsertEventSeries(EventSeries series, IEnumerable<Localization> localizations, UserCredentials login) { using (var db = login.GetConnection()) using (var t = new Transaction(db)) { db.Insert(series); var geoString = SerializeLocalizations(localizations); if (!string.IsNullOrWhiteSpace(geoString)) db.Execute("UPDATE [dbo].[CollectionEventSeries] SET geography=GEOGRAPHY::STGeomFromText(@0, 4326) WHERE SeriesID=@1", geoString, series.CollectionEventSeriesID); t.Complete(); return series.CollectionEventSeriesID; } }
public int InsertEventSeries(EventSeries series, IEnumerable<Localization> localizations, UserCredentials login) { using (var db = login.GetConnection()) using (var t = new Transaction(db)) { db.Insert(series); var geoString = SerializeLocalizations(localizations); if (!string.IsNullOrWhiteSpace(geoString)) db.Execute("Update [dbo].[CollectionEventSeries] Set geography=@0 Where SeriesID=@1", geoString, series.CollectionEventSeriesID); t.Complete(); return series.CollectionEventSeriesID; } }