private async Task LoadProgrammeForEditAsync(int id) { ProgrammeDataService programmeDataService = new ProgrammeDataService(new EntityFramework.TimetableManagerDbContext()); programme = await programmeDataService.GetProgrammeById(id); textBoxshortame.Text = programme.ProgrammeShortName; textBoxfullname.Text = programme.ProgrammeFullName; isEditState = true; }
private void DeleteButton_Click(object sender, RoutedEventArgs e) { Programme programme = (Programme)dataGridprogramme.SelectedItem; ProgrammeDataService programmeDataService = new ProgrammeDataService(new EntityFramework.TimetableManagerDbContext()); programmeDataService.DeleteProgramme(programme.ProgrammeId).ContinueWith(result => { MessageBox.Show("Deleted"); }); _ = programmeDataList.Remove(programme); }
public async Task load() { ProgrammeDataService programmeDataService = new ProgrammeDataService(new EntityFramework.TimetableManagerDbContext()); programmeList = await programmeDataService.GetProgramme(); programmeList.ForEach(e => { Programme l = new Programme(); l.ProgrammeId = e.ProgrammeId; l.ProgrammeFullName = e.ProgrammeFullName; l.ProgrammeShortName = e.ProgrammeShortName; programmeDataList.Add(l); }); }
private async void btnSave_Click(object sender, RoutedEventArgs e) { var programmeDataService = new ProgrammeDataService(new EntityFramework.TimetableManagerDbContext()); if (textBoxfullname.Text != "" || textBoxshortame.Text != "") { if (isEditState) { isEditState = false; programme.ProgrammeFullName = textBoxfullname.Text; programme.ProgrammeShortName = textBoxshortame.Text; await programmeDataService.UpdateProgramme(programme, programme.ProgrammeId).ContinueWith(result => { if (result != null) { MessageBox.Show("Updated Successfully!", "Success"); } }); } else { Programme newProgramme = new Programme { ProgrammeFullName = textBoxfullname.Text, ProgrammeShortName = textBoxshortame.Text }; await programmeDataService.AddProgramme(newProgramme); } textBoxfullname.Clear(); textBoxshortame.Clear(); } else { MessageBox.Show("fill all fields!!"); } this.programmeDataList.Clear(); _ = this.load(); }
private async Task LoadDataForGenerate() { var groupIdDataService = new GroupIdDataService(new EntityFramework.TimetableManagerDbContext()); Year_SemesterDataService year_SemesterDataService = new Year_SemesterDataService(new EntityFramework.TimetableManagerDbContext()); List <Year_Semester> YsList = await year_SemesterDataService.GetYs(); List <string> YearNameList = new List <string>(); YsList.ForEach(e => { YearNameList.Add(e.YsShortName); }); ProgrammeDataService programmeDataService = new ProgrammeDataService(new EntityFramework.TimetableManagerDbContext()); List <Programme> programmeList = await programmeDataService.GetProgramme(); List <string> ProgrammeNameList = new List <string>(); programmeList.ForEach(e => { ProgrammeNameList.Add(e.ProgrammeShortName); }); GroupNumberDataService groupNumberDataService = new GroupNumberDataService(new EntityFramework.TimetableManagerDbContext()); List <GroupNumber> GroupNumberList = await groupNumberDataService.GetGroupNumbers(); List <string> GroupNameList = new List <string>(); GroupNumberList.ForEach(e => { GroupNameList.Add(e.GroupNum); }); List <string> GeneratedList = new List <string>(); YearNameList.ForEach(y => { ProgrammeNameList.ForEach(p => { GroupNameList.ForEach(g => { string id = String.Concat(y, ".", p, ".", g); GeneratedList.Add(id); }); }); }); GeneratedList.ForEach(async e => { _ = await groupIdDataService.AddGroupId(new GroupId { GroupID = e }); GroupIdDataList.Add(new GroupId { GroupID = e }); }); }