private async Task OnLoadData() { await _dataService.InitialiseAsync().ConfigureAwait(false); var departments = _dataService.GetAllDepartments(); var people = _dataService.GetAllPeople(); _departmentVmList.Clear(); _departmentVmList.AddRange(departments.Select(d => new DepartmentViewModel { Model = d })); _personVmList.Clear(); _personVmList.AddRange(people.Select(p => new PersonViewModel { Model = p })); foreach (var personVm in _personVmList) { var departmentVm = _departmentVmList.FirstOrDefault(d => d.Model.Id == personVm.Model.DepartmentId); departmentVm?.AddPerson(personVm); } _personVmList.Sort(); SelectedPersonVm = _personVmList.FirstOrDefault(); }
private async Task RefreshDataAsync() { await _dataService.InitialiseAsync().ConfigureAwait(false); var departments = _dataService.GetAllDepartments(); smViewModelFactory.BuildAllDepartmentVms(departments); var rootTreeItem = perIoC.GetInstance <AllDepartmentsViewModel>(); _rootTreeItemsList.Clear(); _rootTreeItemsList.Add(rootTreeItem); // this will trigger lazy loading for the department items rootTreeItem.IsExpanded = true; SelectedItem = rootTreeItem; }
public Task InitialiseAsync() { _dataService = new StaffManagerDataService(); return(_dataService.InitialiseAsync()); }