public async Task <int> GetCountAsync(string species) { using (var context = new PorpoiseSightingsContext()) { return(await context.PorpoiseSightings.CountAsync(x => x.Species.Equals(species))); } }
public async Task <List <PorpoiseSighting> > GetAsync() { using (var context = new PorpoiseSightingsContext()) { return(await context.PorpoiseSightings.ToListAsync()); } }
public async Task <SpeciesModel> LoadSpectacledPorpoiseModelAsync() { using (var context = new PorpoiseSightingsContext()) { return(await context.SpeciesModels.FirstOrDefaultAsync(x => x.Species.Equals("SpectacledPorpoise"))); } }
public async Task AddAsync(PorpoiseSighting porpoise) { using (var context = new PorpoiseSightingsContext()) { context.PorpoiseSightings.Add(porpoise); await context.SaveChangesAsync(); } }
public async Task AddAsync(SightingTrip sightingTrip) { using (var context = new PorpoiseSightingsContext()) { context.SightingTrips.Add(sightingTrip); await context.SaveChangesAsync(); } }
public async Task UpdateAsync(PorpoiseSighting porpoiseSighting) { using (var context = new PorpoiseSightingsContext()) { var porpoiseSightingDb = context.PorpoiseSightings.FirstOrDefault(x => x.Id == porpoiseSighting.Id); porpoiseSightingDb.Name = porpoiseSighting.Name; porpoiseSightingDb.Species = porpoiseSighting.Species; porpoiseSightingDb.Latitude = porpoiseSighting.Latitude; porpoiseSightingDb.Longitude = porpoiseSighting.Longitude; porpoiseSightingDb.Time = porpoiseSighting.Time; await context.SaveChangesAsync(); } }
public async Task UpdateAsync(SightingTrip sightingTrip) { using (var context = new PorpoiseSightingsContext()) { var sightingTripDb = await context.SightingTrips.FirstOrDefaultAsync(x => x.Id == sightingTrip.Id); if (sightingTripDb != null) { sightingTripDb.Captain = sightingTrip.Captain; sightingTripDb.DepartureTime = sightingTrip.DepartureTime; await context.SaveChangesAsync(); } } }