예제 #1
0
 public async Task <int> GetCountAsync(string species)
 {
     using (var context = new PorpoiseSightingsContext())
     {
         return(await context.PorpoiseSightings.CountAsync(x => x.Species.Equals(species)));
     }
 }
예제 #2
0
 public async Task <List <PorpoiseSighting> > GetAsync()
 {
     using (var context = new PorpoiseSightingsContext())
     {
         return(await context.PorpoiseSightings.ToListAsync());
     }
 }
예제 #3
0
 public async Task <SpeciesModel> LoadSpectacledPorpoiseModelAsync()
 {
     using (var context = new PorpoiseSightingsContext())
     {
         return(await context.SpeciesModels.FirstOrDefaultAsync(x => x.Species.Equals("SpectacledPorpoise")));
     }
 }
예제 #4
0
 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();
     }
 }
예제 #6
0
 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();
                }
            }
        }