public async Task AddAsync(SightingTrip sightingTrip)
 {
     using (var context = new PorpoiseSightingsContext())
     {
         context.SightingTrips.Add(sightingTrip);
         await context.SaveChangesAsync();
     }
 }
 public void Add(SightingTrip trip)
 {
     using (var context = new WhaleSightingsContext())
     {
         context.SightingTrips.Add(trip);
         context.SaveChanges();
     }
 }
        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();
            }
        }
        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();
                }
            }
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #7
0
 public void UpdateSightingTrip(SightingTrip sightingTrip)
 {
     _sightingTripRepository.Update(sightingTrip);
 }
Beispiel #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);
 }