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 <Person> GetAllPeople() { var allPeople = _dataService.GetAllPeople(); var result = new List <Person>(); foreach (var person in allPeople) { var mockPerson = person.CloneAllFields(); mockPerson.LastName += " (Mock)"; result.Add(mockPerson); } return(result.AsReadOnly()); }