private void CancelRentButton_Click(object sender, RoutedEventArgs e) { if (DataGridBox.SelectedItem != null) { Warning warn = new Warning("Are you sure?"); warn.ShowDialog(); if (isRemoved) { WSCalendar temp = (WSCalendar)DataGridBox.SelectedItem; calendarService.deleteRent(temp.id); } } DataGridBox.ClearValue(ItemsControl.ItemsSourceProperty); DataGridBox.Items.Clear(); if (RenterToggle.IsChecked == true) { RenterCombobox.IsEnabled = true; loadLandlordColumns(); } else { RenterCombobox.IsEnabled = false; loadTenantColumns(); } }
private void loadLandlordColumns() { RenterCombobox.IsEnabled = true; List <Addresses> userAddresses = calendarService.getUserAddresses(LoginService.userId); List <long> addressIds = userAddresses.Select(c => c.id).ToList(); rents = calendarService.getRenterFutureRents(addressIds); for (int i = 0; i < userAddresses.Count; i++) { RenterCombobox.Items.Add(userAddresses[i].street); DateTime date = new DateTime(2020, 10, 10); } List <WSCalendar> calendarList = new List <WSCalendar>(); for (int i = 0; i < rents.Count; i++) { WSCalendar temp = new WSCalendar(); temp.id = rents[i].id; temp.startDate = rents[i].startDate.ToShortDateString(); temp.endDate = rents[i].endDate.ToShortDateString(); temp.address = calendarService.getAddress(rents[i].address_id); temp.client = calendarService.getPerson(rents[i].user_id); calendarList.Add(temp); } LoadGrid(calendarList); }
private void loadTenantColumns() { RenterCombobox.IsEnabled = false; rents = calendarService.getUserFutureRents(LoginService.userId); List <WSCalendar> calendarList = new List <WSCalendar>(); for (int i = 0; i < rents.Count; i++) { WSCalendar temp = new WSCalendar(); temp.id = rents[i].id; temp.startDate = rents[i].startDate.ToShortDateString(); temp.endDate = rents[i].endDate.ToShortDateString(); temp.address = calendarService.getAddress(rents[i].address_id); temp.client = calendarService.getPerson(rents[i].user_id); calendarList.Add(temp); } LoadGrid(calendarList); }