private async void PART_Stepper_ContinueNavigation(object sender, MaterialDesignExtensions.Controls.StepperNavigationEventArgs args) { // 发送申请 DonationMaterialListViewModel selected = (DonationMaterialListViewModel)MaterialSelectListBox.SelectedItem; if (selected == null) { MainWindow.SetSnackBarContentAndPopup("请选择要捐赠的物资"); args.Cancel = true; return; } else if (QuantityInputBox.Value == null || QuantityInputBox.Value <= 0) { MainWindow.SetSnackBarContentAndPopup("不合法的数目"); args.Cancel = true; return; } NewDonationResponse response = await NetworkHelper.GetAsync(new NewDonationRequest() { MaterialId = selected.OriginItem.Id, Quantity = (int)QuantityInputBox.Value, Address = UserInfo.HomeAddress }).Progress(ParentWindow.PART_ProgressBar); DonationViewModel = new DonationListViewModel(response.Item); DonationDetailViewModel = new DonationDetailViewModel(await NetworkHelper.GetAsync(new GetDonationDetailRequest() { UserId = UserInfo.Id, DonationId = DonationViewModel.OriginalItem.ID }).Progress(ParentWindow.PART_ProgressBar)); RefreshApplicationCardView(); }
private async void Page_Loaded(object sender, RoutedEventArgs e) { if (DonationViewModel != null) { // 查看已存在的捐赠 // 1. 网络请求 DonationDetailViewModel = new DonationDetailViewModel(await NetworkHelper.GetAsync(new GetDonationDetailRequest() { UserId = UserInfo.Id, DonationId = DonationViewModel.OriginalItem.ID }).Progress(ParentWindow.PART_ProgressBar)); // 2. 根据DonationViewModel来生成正确的Tab显示 switch (DonationViewModel.OriginalItem.State) { case DonationState.Applying: PART_Stepper.Controller.GotoStep(1); break; case DonationState.WaitingDelivery: case DonationState.Delivering: PART_Stepper.Controller.GotoStep(2); break; case DonationState.Done: PART_Stepper.Controller.GotoStep(3); break; default: PART_Stepper.Controller.GotoStep(1); break; } } else { // 填写新申请 // 1. 请求所有可选的物资 AvailableDonationMaterialResponse response = await NetworkHelper.GetAsync(new AvailableDonationMaterialRequest() { }) .Progress(ParentWindow.PART_ProgressBar); MaterialListViewModels = new ObservableCollection <DonationMaterialListViewModel>(response.Items.Select(i => new DonationMaterialListViewModel(i))); MaterialSelectListBox.ItemsSource = MaterialListViewModels; // 2. 初始化好填写界面 RefreshAddressInfo(); PART_Stepper.Controller.GotoStep(0); } RefreshApplicationCardView(); }