private void DeleteButtonbuilding_Click(object sender, RoutedEventArgs e) { BuildingGridModel build = (BuildingGridModel)dataGridBuilding.SelectedItem; BuildingDataService buildingdataservice = new BuildingDataService(new EntityFramework.TimetableManagerDbContext()); buildingdataservice.deleteBuilding(build.BuildingId).ContinueWith(result => { MessageBox.Show("Deleted"); }); _ = BuildingDataList.Remove(build); }
private async Task LoadBuildingData() { BuildingDataService buildingdataservice = new BuildingDataService(new EntityFramework.TimetableManagerDbContext()); BuildingList = await buildingdataservice.GetBuildingsAsync(); BuildingList.ForEach(f => { BuildingGridModel buildingobj = new BuildingGridModel(); buildingobj.BuildingId = f.BuildingId; buildingobj.BuildingName = f.BuildingName; buildingobj.CenterName = f.Center.CenterName; BuildingDataList.Add(buildingobj); }); }
private void SaveBuildingButton_Click(object sender, RoutedEventArgs e) { Building building = new Building(); building.BuildingName = textBoxBuilding.Text.Trim(); string centerName = CenComboBox.SelectedItem.ToString(); BuildingDataService buildingDataService = new BuildingDataService(new EntityFramework.TimetableManagerDbContext()); if (CenComboBox.IsEnabled) { buildingDataService.AddBuilding(building, centerName).ContinueWith(result => { if (result != null) { MessageBox.Show("Building Added!", "Success"); } else { MessageBox.Show("Sorry! Error occured!", "Error"); } }); } else { CenComboBox.IsEnabled = true; _ = buildingDataService.deleteBuilding(BuildingId); buildingDataService.AddBuilding(building, centerName).ContinueWith(result => { if (result != null) { MessageBox.Show("Building Updated!", "Success"); } else { MessageBox.Show("Sorry! Error occured!", "Error"); } }); } BuildingDataList.Clear(); _ = this.LoadBuildingData(); }