/// <summary> /// Reloads the lookupList /// </summary> /// <returns></returns> private async Task ReloadList() { IsLoading = true; var reply = await _lookupApiService.GetAll(); if (reply != null) { var list = reply.Select(value => new LookupListItemViewModel <T>(value, OnListItemDoubleClickCommand, OnLockCommand)).ToList(); Values = new ObservableCollection <LookupListItemViewModel <T> >(list); } else { Values = new ObservableCollection <LookupListItemViewModel <T> >(); } }
/// <summary> /// Initializer /// </summary> /// <returns></returns> protected override async Task InitializeAsync() { try { IsLoading = true; //var employees = await _employeeApiService.GetAll(); //if (employees != null) //{ // var result = employees.Select(employee => new EmployeeListItemViewModel(employee)).ToList(); // Employees = new ObservableCollection<EmployeeListItemViewModel>(result); //} //else //{ // Employees = new ObservableCollection<EmployeeListItemViewModel>(); //} var departmentList = await _departmentApiService.GetAll(); if (departmentList != null) { Departments = new ObservableCollection <DepartmentDto>(departmentList); } else { Departments = new ObservableCollection <DepartmentDto>(); } var sectionList = await _sectionApiService.GetAll(); if (sectionList != null) { Sections = new ObservableCollection <SectionDto>(sectionList); } else { Sections = new ObservableCollection <SectionDto>(); } } catch (Exception e) { _loggingService.LogFatal("Error during Employee list initialization", e); _dialogService.ShowError(e.Message); } finally { IsLoading = false; } }
/// <summary> /// Async data loading during initialization /// </summary> /// <returns></returns> protected override async Task InitializeAsync() { try { IsLoading = true; var itemNatureList = await _itemNatureApiService.GetAll(); ItemNatures = new ObservableCollection <ItemNatureDto>(itemNatureList); } catch (Exception e) { _loggingService.LogFatal("Error during Initialization!", e); _dialogService.ShowError(e.Message); } finally { IsLoading = false; } }
/// <summary> /// Async data loading during initialization /// </summary> /// <returns></returns> protected override async Task InitializeAsync() { try { IsLoading = true; var floorList = await _floorApiService.GetAll(); Floors = new ObservableCollection <FloorDto>(floorList); var departmentList = await _departmentApiService.GetAll(); Departments = new ObservableCollection <DepartmentDto>(departmentList); } catch (Exception e) { _loggingService.LogFatal("Error during Initialization!", e); _dialogService.ShowError(e.Message); } finally { IsLoading = false; } }
/// <summary> /// Initialization /// </summary> /// <returns></returns> protected override async Task InitializeAsync() { try { IsLoading = true; if (Parameter != null) { SelectedBuildings = new ObservableCollection <BuildingDto>(Parameter.Buildings); SelectedDepartments = new ObservableCollection <DepartmentDto>(Parameter.Departments); SelectedFloors = new ObservableCollection <FloorDto>(Parameter.Floors); SelectedItemNatures = new ObservableCollection <ItemNatureDto>(Parameter.ItemNatures); SelectedItemStates = new ObservableCollection <ItemStateDto>(Parameter.ItemStates); SelectedItemTypes = new ObservableCollection <ItemTypeDto>(Parameter.ItemTypes); SelectedLocations = new ObservableCollection <LocationDto>(Parameter.Locations); SelectedSections = new ObservableCollection <SectionDto>(Parameter.Sections); } else { SelectedBuildings = new ObservableCollection <BuildingDto>(); SelectedDepartments = new ObservableCollection <DepartmentDto>(); SelectedFloors = new ObservableCollection <FloorDto>(); SelectedItemNatures = new ObservableCollection <ItemNatureDto>(); SelectedItemStates = new ObservableCollection <ItemStateDto>(); SelectedItemTypes = new ObservableCollection <ItemTypeDto>(); SelectedLocations = new ObservableCollection <LocationDto>(); SelectedSections = new ObservableCollection <SectionDto>(); } var buildingList = await _buildingApiService.GetAll(); var departmentList = await _departmentApiService.GetAll(); var floorList = await _floorApiService.GetAll(); var itemNatureList = await _itemNatureApiService.GetAll(); var itemStateList = await _itemStateApiService.GetAll(); var itemTypeList = await _itemTypeApiService.GetAll(); var locationList = await _locationApiService.GetAll(); var sectionList = await _sectionApiService.GetAll(); if (buildingList != null) { var buildings = buildingList.Where(building => SelectedBuildings.FirstOrDefault(building2 => building.Id == building2.Id) == null).ToList(); NotSelectedBuildings = new ObservableCollection <BuildingDto>(buildings); } if (departmentList != null) { var departments = departmentList.Where(department => SelectedDepartments.FirstOrDefault(department2 => department.Id == department2.Id) == null).ToList(); NotSelectedDepartments = new ObservableCollection <DepartmentDto>(departments); } if (floorList != null) { var floors = floorList.Where(floor => !SelectedFloors.Contains(floor)).ToList(); NotSelectedFloors = new ObservableCollection <FloorDto>(floors); } if (itemNatureList != null) { var itemNatures = itemNatureList.Where(itemNature => SelectedItemNatures.FirstOrDefault(itemNature2 => itemNature.Id == itemNature2.Id) == null).ToList(); NotSelectedItemNatures = new ObservableCollection <ItemNatureDto>(itemNatures); } if (itemStateList != null) { var itemStates = itemStateList.Where(itemState => SelectedItemStates.FirstOrDefault(itemState2 => itemState.Id == itemState2.Id) == null).ToList(); NotSelectedItemStates = new ObservableCollection <ItemStateDto>(itemStates); } if (itemTypeList != null) { var itemTypes = itemTypeList.Where(itemType => SelectedItemTypes.FirstOrDefault(itemType2 => itemType.Id == itemType2.Id) == null).ToList(); NotSelectedItemTypes = new ObservableCollection <ItemTypeDto>(itemTypes); } if (locationList != null) { var locations = locationList.Where(location => SelectedLocations.FirstOrDefault(location2 => location.Id == location2.Id) == null).ToList(); NotSelectedLocations = new ObservableCollection <LocationDto>(locations); } if (sectionList != null) { var sections = sectionList.Where(section => SelectedSections.FirstOrDefault(section2 => section.Id == section2.Id) == null).ToList(); NotSelectedSections = new ObservableCollection <SectionDto>(sections); } } catch (Exception e) { _loggingService.LogFatal("Error during Initalization!", e); _dialogService.ShowError(e.Message); } finally { IsLoading = false; } }