public function updateDashboard()
    {
        $dashboardId = (int) $this->request->postVar('dashboard');
        $items = (array) $this->request->postVar('order');
        
        if ($dashboardId) {
            $dashboard = $this->dataService->memberDashboardById($dashboardId);
            if ($dashboard && $dashboard->exists()) {
                $dashboard->Widgets()->removeAll();
                if (is_array($items)) {
                    foreach ($items as $i => $widgetId) {
                        $widget = $this->dataService->dashletById($widgetId);
                        if ($widget) {
                            $widget->ParentID = $dashboard->ID;
                            $widget->Sort = $i+1;    // need +1 here so there's no 0 sort val, otherwise onbeforewrite sets it automatically.
                            $widget->write();
                        }
                    }
                }
            }
        }
    }