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(); } } }