async void Handle_DateClicked(object sender, XamForms.Controls.DateTimeEventArgs e) { ResetLayout(); if (calendar.SelectedDate < DateTime.Now) { timeSlotGrid.IsVisible = false; } else { timeSlotGrid.IsVisible = true; selectedDate = calendar.SelectedDate.Value.Year + "-" + calendar.SelectedDate.Value.Month + "-" + calendar.SelectedDate.Value.Day; var result = await service.FacilityScreen(App.Current.Properties["defaultPid"].ToString(), facilityId, selectedDate); if (result != null) { if (result.status_code == System.Net.HttpStatusCode.OK) { int i = 0; if (result.availableBookingTimeSlotList != null) { availableSlots = result.availableBookingTimeSlotList; } foreach (var item in availableSlots) { var button = new BookingButton { Text = item.startTime + " - " + item.endTime, StyleId = item.tId }; buttonArray.Add(item.tId, button); button.Clicked += Button_Clicked; timeSlotGrid.Children.Add(button, i % 4, i / 4); i++; } } else if (result.status_code == System.Net.HttpStatusCode.BadRequest) { await DisplayAlert("Error", "Facility booking setup is incomplete", "OK"); await Navigation.PopAsync(true); } } } }
async void Handle_DateClicked(object sender, XamForms.Controls.DateTimeEventArgs e) { selectedDate = calendar.SelectedDate.Value.Year + "-" + calendar.SelectedDate.Value.Month + "-" + calendar.SelectedDate.Value.Day; ResetLayout(); var result = await service.FacilityScreen(App.Current.Properties["defaultPid"].ToString(), facilityId, parent.selectedUnit.unitId, parent.selectedTenant.tenantId, selectedDate); if (result != null) { if (result.status_code == System.Net.HttpStatusCode.OK) { timeSelector.Text = "Select all slots you would like to book"; timeSlotGrid.IsVisible = true; int i = 0; if (result.availableBookingTimeSlotList != null) { availableSlots = result.availableBookingTimeSlotList; } if (result.reservedBookingTimeSlotList != null) { reservedSlots = result.reservedBookingTimeSlotList; } foreach (var item in availableSlots) { var button = new BookingButton { Text = item.startTime + " - " + item.endTime, StyleId = item.tId }; buttonArray.Add(item.tId, button); button.Clicked += Button_Clicked; timeSlotGrid.Children.Add(button, i % 4, i / 4); i++; } int j = 0; if (result.reservedBookingTimeSlotList != null) { if (result.reservedBookingTimeSlotList.Count > 0) { showAllButton.IsVisible = true; foreach (var item in result.reservedBookingTimeSlotList) { var button = new BookingButton { Text = item.startTime + " - " + item.endTime, StyleId = item.tId }; nonAvailableButtonArray.Add(item.tId, button); unavailableSlotGrid.Children.Add(button, j % 4, j / 4); j++; } } } else { showAllButton.IsVisible = false; notifyFrame.IsVisible = false; } depositFee = result.deposit; } else if (result.status_code == System.Net.HttpStatusCode.BadRequest) { await DisplayAlert("Error", "Facility booking setup is incomplete", "OK"); await Navigation.PopAsync(true); } } }