Location CreateLocation(string locationName, string comments, GeoRect geoRect) { var existing = (from l in Globals.MasterDatabaseService.Context.Locations where l.Name == locationName select l).FirstOrDefault(); if (existing != null) throw new DuplicateNameException(String.Format("A location named {0} already exists, choose another name", locationName)); var location = new Location { Name = locationName, Comments = comments, GeoRect = geoRect, LayerSettings = { IsChecked = true, LineOrSymbolSize = 5 } }; Globals.MasterDatabaseService.Context.Locations.Local.Add(location); location.UpdateMapLayers(); return location; }