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