public async Task <bool> AddGeolocation(GeolocationModel geolocationModel) { try { using (GeolocationsContext ctx = new GeolocationsContext()) { ctx.Geolocations.Add(geolocationModel); return(await ctx.SaveChangesAsync() > 0); } } catch (Exception ex) { _logger.Error("Saving geolocation error " + ex.Message); throw ex; } }
public async Task <bool> DeleteGeolocation(Guid geolocationModelGuid) { using (GeolocationsContext ctx = new GeolocationsContext()) { try { var geolocationToDelete = await ctx.Geolocations.SingleOrDefaultAsync(x => x.Id == geolocationModelGuid); ctx.Geolocations.Remove(geolocationToDelete); return(await ctx.SaveChangesAsync() > 0); } catch (Exception ex) { _logger.Error("Deleting geolocation error" + ex.Message); throw ex; } } }