private void btnBoka_Click(object sender, EventArgs e) { try { // Kolla vad som är valt int cabinIndex = lvwBokaStuga.SelectedItems[0].Index; int customerIndex = lvwBokaKund.SelectedItems[0].Index; if (cabinList.Get(cabinIndex).CabinAvailable == true) { cabinList.Get(cabinIndex).CabinAvailable = false; cabinList.Get(cabinIndex).CabinFreeFrom = dtpLeaving.Value; //Hämtar information för bokningen från cabinList och customerlist //genom att kolla på den valda raden. Bokningen är automatiskt inte betald. int customerID = customerList.Get(customerIndex).CustomerID; int cabinID = cabinList.Get(cabinIndex).CabinID; int bookingID = bookingList.Count() + 1; //Kolla om husvagn ska användas //om den ska användas, använd värdet 1000 för att visa i listviewen att det är en husvagn if (cbxHusvagn.Checked == true) { Booking booking = new Booking(bookingID, customerID, 1000, dtpArriving.Value, dtpLeaving.Value, false); bookingList.Add(booking); } else { Booking booking = new Booking(bookingID, customerID, cabinID, dtpArriving.Value, dtpLeaving.Value, false); bookingList.Add(booking); } updateBookingListView(); updateCabinListView(); updateCustomerListView(); } else { MessageBox.Show("Stugan är ej ledig"); } } catch (Exception ex) { MessageBox.Show(ex.Message); MessageBox.Show("Välj en kund och en stuga"); updateCabinListView(); } }
public async Task AllBookings() { var customerID = await _serviceCustomer.GetById <Data.Model.Customer>(APIService.CustomerId); customer = customerID; var request = new BookingSearchRequest { CustomerID = customer.CustomerId }; BookingList.Clear(); var list = await _serviceBooking.Get <List <Data.Model.Booking> >(request); foreach (var item in list) { item.EndDate = item.EndDate.AddHours(8).Date; BookingList.Add(item); } if (BookingList.Count == 0) { await Application.Current.MainPage.DisplayAlert("Warning", "You don't have any bookings yet.", "OK"); } }
public async Task Initialization() { var customerID = await _serviceCustomer.GetById <Data.Model.Customer>(APIService.CustomerId); customer = customerID; var request = new BookingSearchRequest { CustomerID = customer.CustomerId }; BookingList.Clear(); var list = await _serviceBooking.Get <List <Data.Model.Booking> >(request); foreach (var item in list) { if (item.RatingStatus == false && item.EndDate.Date <= DateTime.Now.Date) { BookingList.Add(item); } } if (BookingList.Count == 0) { await Application.Current.MainPage.DisplayAlert("Warning", "The list is empty. You can leave a rating on the reserved vehicle after the reservation expires or you have not booked yet. Please, try again later.", "OK"); } }
private void LoadBookings() { BookingList.Clear(); IEnumerable <Booking> bookings = repository.GetBookings(); foreach (Booking item in bookings) { BookingList.Add(item); } }
/// <summary> /// Creates a new booking item, selects it and adds it to the BookingList /// </summary> /// <param name="date"></param> /// <param name="description"></param> public void NewBookingItem(DateTime date, string description) { if (string.IsNullOrEmpty(description)) { throw new Exception("Bitte Kontenrahmen angeben."); } Booking booking = new Booking(date, description); booking.BookingId = tempBookingId; tempBookingId++; SelectedBooking = booking; if (BookingList == null) { BookingList = new ObservableCollection <Booking>(); } BookingList.Add(booking); }
public async Task SearchBookingCar() { if (EndDate == StartDate) { await Application.Current.MainPage.DisplayAlert("Warning", "The search interval should be at least 1 day", "Try again"); return; } if (EndDate <= StartDate) { await Application.Current.MainPage.DisplayAlert("Warning", "End date must be greater than start date", "Try again"); return; } var request = new BookingSearchRequest { ManufacturerName = ManufacturerName, StartDate = StartDate, EndDate = EndDate }; var list = await _serviceBooking.Get <IEnumerable <Data.Model.Booking> >(request); BookingList.Clear(); foreach (var item in list) { item.EndDate = item.EndDate.AddHours(8).Date; BookingList.Add(item); } if (BookingList.Count == 0) { await Application.Current.MainPage.DisplayAlert("Warning", "There are no results for this search", "Try again"); } }