private async void ExecuteEditHouseCommand(object key) { var values = (object[])key; this.ModifiedHouse = NhaDAO.GetInstance().GetHouseById(values); this.ModifiedRentalHouseDetail = ChiTietNhaThueDAO.GetInstance().GetRentalhouseDetailById(values); var selectedhHouseCate = this.allHouseCategories.FirstOrDefault(c => c.MALOAI == this.ModifiedHouse.MALOAI); var cateIndex = this.allHouseCategories.IndexOf(selectedhHouseCate); this.HouseDetailViewModel = new HouseDetailViewModel { HouseCateSelectedIndex = cateIndex, SelectedHouse = this.ModifiedHouse, SelectedRentalHouseDetail = this.ModifiedRentalHouseDetail, AgenciesCollection = this.allAgencies, HouseOwnersCollection = this.allHouseOwners, StaffsCollection = this.allStaffs, HouseCatesCollection = this.allHouseCategories }; var view = new HouseDetailDialog { DataContext = this.HouseDetailViewModel }; //show the dialog var result = await DialogHost.Show(view, BaseMainWindowViewModel.Instance.Identifier, ExtendedOpenedEventHandler, EditHouseClosingEventHandler).ConfigureAwait(false); //check the result... Console.WriteLine("Dialog was closed, the CommandParameter used to close it was: " + (result ?? "NULL")); }
private void Load() { this.HousesCollection = NhaDAO.GetInstance().GetAllHouses(); this.allAgencies = ChiNhanhDAO.GetInstance().GetAllAgencies(); this.allHouseOwners = ChuNhaDAO.GetInstance().GetAllHousOwners(); this.allStaffs = NhanVienDAO.GetInstance().GetAllStaffs(); this.allHouseCategories = LoaiNhaDAO.GetInstance().GetAllHouseCategories(); }
private void AddNewHouseClosingEventHandler(object sender, DialogClosingEventArgs eventArgs) { if (eventArgs.Parameter is bool parameter && !parameter) { return; } var House = this.HouseDetailViewModel.SelectedHouse; NhaDAO.GetInstance().AddNewHouse(House); Load(); }
private void DeleteExtendedClosingEventHandler(object sender, DialogClosingEventArgs eventArgs) { if (eventArgs.Parameter is bool parameter && !parameter) { return; } var selectHouseCate = this.allHouseCategories[this.HouseDetailViewModel.HouseCateSelectedIndex]; this.HouseDetailViewModel.SelectedHouse.MALOAI = selectHouseCate.MALOAI; ChiTietNhaThueDAO.GetInstance().DeleteRentalhouseDetail(this.HouseDetailViewModel.SelectedRentalHouseDetail); NhaDAO.GetInstance().DeleteHouse(this.HouseDetailViewModel.SelectedHouse); Load(); }
private async void ExecuteDeleteHouseCommand(object key) { var values = (object[])key; this.ModifiedHouse = NhaDAO.GetInstance().GetHouseById(values); this.ModifiedRentalHouseDetail = ChiTietNhaThueDAO.GetInstance().GetRentalhouseDetailById(values); var okeCancelDialogViewModel = new OkCancelDialogViewModel { Message = "Xóa nhà này?" }; var view = new OkCancelDialogControl { DataContext = okeCancelDialogViewModel }; //show the dialog var result = await DialogHost.Show(view, BaseMainWindowViewModel.Instance.Identifier, ExtendedOpenedEventHandler, DeleteExtendedClosingEventHandler).ConfigureAwait(false); //check the result... Console.WriteLine("Dialog was closed, the CommandParameter used to close it was: " + (result ?? "NULL")); }