Ejemplo n.º 1
0
 public async Task AddAsync(SightingTrip sightingTrip)
 {
     using (var context = new PorpoiseSightingsContext())
     {
         context.SightingTrips.Add(sightingTrip);
         await context.SaveChangesAsync();
     }
 }
Ejemplo n.º 2
0
 public void Add(SightingTrip trip)
 {
     using (var context = new WhaleSightingsContext())
     {
         context.SightingTrips.Add(trip);
         context.SaveChanges();
     }
 }
Ejemplo n.º 3
0
        public void Update(SightingTrip trip)
        {
            using (var context = new WhaleSightingsContext())
            {
                var sightingTripDb = context.SightingTrips.FirstOrDefault(x => x.Id == trip.Id);
                sightingTripDb.Captain       = trip.Captain;
                sightingTripDb.DepartureTime = trip.DepartureTime;

                context.SaveChanges();
            }
        }
Ejemplo n.º 4
0
        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();
                }
            }
        }
Ejemplo n.º 5
0
        // PUT: api/SightingTrips/5
        public async Task PutAsync(int id, [FromBody] SightingTripDTO sightingTrip)
        {
            SightingTrip tripEntity = new SightingTrip()
            {
                Captain           = sightingTrip.Captain,
                DepartureTime     = sightingTrip.DepartureTime,
                PorpoiseSightings = sightingTrip.Sightings.Select(s => new PorpoiseSighting()
                {
                    Latitude  = s.Latitude,
                    Longitude = s.Longitude,
                    Name      = s.Name,
                    Species   = s.Species,
                    Time      = s.Time
                }).ToList()
            };

            await _sightingTripManagementService.UpdateSightingTripAsync(tripEntity);
        }
Ejemplo n.º 6
0
        public void UpdateSightingTrip(SightingTripDTO sightingTrip)
        {
            SightingTrip tripEntity = new SightingTrip()
            {
                Captain        = sightingTrip.Captain,
                DepartureTime  = sightingTrip.DepartureTime,
                WhaleSightings = sightingTrip.Sightings.Select(x => new
                                                               WhaleSighting()
                {
                    Latitude  = x.Latitude,
                    Longitude = x.Longitude,
                    Name      = x.Name,
                    Species   = x.Species,
                    Time      = x.Time
                }).ToList()
            };

            _sightingTripManagementService.UpdateSightingTrip(tripEntity);
        }
Ejemplo n.º 7
0
 public void UpdateSightingTrip(SightingTrip sightingTrip)
 {
     _sightingTripRepository.Update(sightingTrip);
 }
Ejemplo n.º 8
0
 public void AddSightingTrip(SightingTrip sightingTrip)
 {
     _sightingTripRepository.Add(sightingTrip);
 }
 public async Task UpdateSightingTripAsync(SightingTrip sightingTrip)
 {
     await _sightingTripRepository.UpdateAsync(sightingTrip);
 }
 public async Task AddSightingTripAsync(SightingTrip sightingTrip)
 {
     await _sightingTripRepository.AddAsync(sightingTrip);
 }