private void GetBookingByCarId() { OnPropertyChanging(nameof(Bookings)); if (this.selectedCar == null) { return; } this.booking.Clear(); List <Booking> bookings = BookingFetcher.GetBookingByCarId(this.selectedCar.Id, this.DbFactory); bookings.ForEach(x => { this.booking.Add(new BookingItem { Id = x.BookingId, CustomerName = x.CustomerName, Car = this.selectedCar, StartDate = x.StartDate, EndDate = x.EndDate }); }); OnPropertyChanged(nameof(Bookings)); }
public object SaveCurrentBooking() { if (this.CanSaveBooking) { if (this.IsNewBooking) { BookingFetcher.SaveBooking(new Booking { CustomerName = this.CurrentBooking.CustomerName, CarId = this.CurrentBooking.Car.Id, StartDate = this.CurrentBooking.StartDate, EndDate = this.CurrentBooking.EndDate }, this.DbFactory); } else { BookingFetcher.UpdateBooking(new Booking { CustomerName = this.CurrentBooking.CustomerName, CarId = this.CurrentBooking.Car.Id, StartDate = this.CurrentBooking.StartDate, EndDate = this.CurrentBooking.EndDate }, this.DbFactory); } GetBookingByCarId(); } return(this.CurrentBooking); }
private void DeleteBooking() { BookingFetcher.DeleteBooking(this.currentBooking.Id, this.DbFactory); }