public LocationVM Add(NewLocVM loc) { Location l = getByLatLng(loc); if (l == null) l = _db.Locations.Add(new Location { Address = loc.Address, LatLng = CreatePoint(loc.Lat, loc.Long) }); _db.SaveChanges(); return new LocationVM { Id = l.Id, Address = l.Address, Lat = l.LatLng.Latitude.Value, Long = l.LatLng.Longitude.Value }; }
private Location getByLatLng(NewLocVM loc) { return _db.Locations.FirstOrDefault(l => l.LatLng.Latitude == loc.Lat && l.LatLng.Longitude == loc.Long); }