public void DeleteDept() { if (selectedDept != null) { Depts.Remove(SelectedDept); } }
private void RemoveDepartment() { using (var db = new CompanyContext()) { var SelectedDept = this.SelectedDept; var query = from item in db.Departments where SelectedDept.DepartmentId == item.DepartmentId select item; var c = query.First(); Depts.Remove(SelectedDept); db.Departments.Remove(c); db.SaveChanges(); } }