private async void btnSave_Click_1(object sender, RoutedEventArgs e) { var year_SemesterDataService = new Year_SemesterDataService(new EntityFramework.TimetableManagerDbContext()); if (textBox.Text != "") { if (isEditState) { year_Semester.YsYear = Year; year_Semester.YsSemester = Semester; year_Semester.YsShortName = YearShortname + "." + SemesterShortname; await year_SemesterDataService.UpdateYs(year_Semester, year_Semester.YsId); isEditState = false; } else { Year_Semester yearSemester = new Year_Semester { YsYear = Year, YsSemester = Semester, YsShortName = YearShortname + "." + SemesterShortname }; await year_SemesterDataService.AddYs(yearSemester); } } else { MessageBox.Show("fill all fields!!"); } YsDataList.Clear(); _ = this.load(); }
private void DeleteButton_Click(object sender, RoutedEventArgs e) { Year_Semester ys = (Year_Semester)dataGridYs.SelectedItem; Year_SemesterDataService year_SemesterDataService = new Year_SemesterDataService(new EntityFramework.TimetableManagerDbContext()); year_SemesterDataService.DeleteYear_Semester(ys.YsId).ContinueWith(result => { MessageBox.Show("Deleted"); }); _ = YsDataList.Remove(ys); }
public async Task load() { Year_SemesterDataService year_SemesterDataService = new Year_SemesterDataService(new EntityFramework.TimetableManagerDbContext()); YsList = await year_SemesterDataService.GetYs(); YsList.ForEach(e => { Year_Semester l = new Year_Semester(); l.YsId = e.YsId; l.YsYear = e.YsYear; l.YsSemester = e.YsSemester; l.YsShortName = e.YsShortName; YsDataList.Add(l); }); }