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(); }
public ReadOnlyCollection <Department> GetAllDepartments() { var allDepartments = _dataService.GetAllDepartments(); var result = new List <Department>(); foreach (var department in allDepartments) { var mockDepartment = department.CloneAllFields(); mockDepartment.Description += " (Mock)"; result.Add(mockDepartment); } return(result.AsReadOnly()); }
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; }