public async Task <bool> AddSubGroupId(SubGroupId subGroupId) { _context.SubGroupIds.Add(subGroupId); int result = await _context.SaveChangesAsync(); if (result > 0) { return(true); } return(false); }
public async Task <int> DeleteAllSubGroupId() { foreach (var id in _context.SubGroupIds.Select(e => e.Id)) { var entity = new SubGroupId { Id = id }; _context.SubGroupIds.Attach(entity); _context.SubGroupIds.Remove(entity); } return(await _context.SaveChangesAsync()); }
private void DeleteButton_Click(object sender, RoutedEventArgs e) { SubGroupId groupId = (SubGroupId)dataGridSubGroupID.SelectedItem; SubGroupIdDataService groupIdDataService = new SubGroupIdDataService(new EntityFramework.TimetableManagerDbContext()); groupIdDataService.DeleteSubGroupId(groupId.Id).ContinueWith(result => { MessageBox.Show("Deleted"); }); _ = SubGroupIdDataList.Remove(groupId); }
public async Task load() { SubGroupIdDataService groupIdDataService = new SubGroupIdDataService(new EntityFramework.TimetableManagerDbContext()); SubGroupIdList = await groupIdDataService.GetSubGroupId(); SubGroupIdList.ForEach(e => { SubGroupId l = new SubGroupId(); l.Id = e.Id; l.SubGroupID = e.SubGroupID; SubGroupIdDataList.Add(l); }); }