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; }
public void MarkAsModified(Booking item) { Entry(item).State = EntityState.Modified; }
public void MarkAsModified(Booking item) { }
public bool ConfirmBooking(Booking booking) { return _postBookingCommand.Execute(booking); }