コード例 #1
0
        public bool Execute(Booking booking)
        {
            // Get booking from database
            var bookingFromDatabase = _db.Bookings.Find(booking.Id);

            if (bookingFromDatabase != null)
            {
                // Map passengersList
                foreach (var passenger in bookingFromDatabase.PassengersList.ToArray())
                {
                    _db.MarkAsDeleted(passenger);
                    bookingFromDatabase.PassengersList.Remove(passenger);
                }

                foreach (var passenger in booking.PassengersList)
                {
                    bookingFromDatabase.PassengersList.Add(passenger);
                }

                //bookingFromDatabase.VehicleType = booking.VehicleType;
                //bookingFromDatabase.TrailerType = booking.TrailerType;
                bookingFromDatabase.Adults = booking.Adults;
                bookingFromDatabase.Childrens = booking.Childrens;
                bookingFromDatabase.Infants = booking.Infants;

                // Save changes in database
                _db.MarkAsModified(bookingFromDatabase);
                _db.SaveChanges();

                return true;
            }

            return false;
        }
コード例 #2
0
 public void MarkAsModified(Booking item)
 {
     Entry(item).State = EntityState.Modified;
 }
コード例 #3
0
 public void MarkAsModified(Booking item) { }
コード例 #4
0
 public bool ConfirmBooking(Booking booking)
 {
     return _postBookingCommand.Execute(booking);
 }