/// <summary> /// Command handler of search command /// </summary> private async void OnSearchCommand() { try { IsLoading = true; var filterInfo = new EmployeeFilterInfo { Name = NameFilter, DepartmentId = SelectedDepartment?.Id, SectionId = SelectedSection?.Id }; var reply = await _employeeApiService.FilterEmployees(filterInfo); if (reply != null) { var result = reply.Select(employee => new EmployeeListItemViewModel(employee)).ToList(); Employees = new ObservableCollection <EmployeeListItemViewModel>(result); } else { Employees = new ObservableCollection <EmployeeListItemViewModel>(); } } catch (Exception e) { _loggingService.LogError("Error during Employee search", e); _dialogService.ShowError(e.Message); } finally { IsLoading = false; } }
protected override async Task InitializeAsync() { try { IsLoading = true; Parameter = new List <int>(); var departemnts = await _departmentApiService.GetAvailable(); DepartmentList = new ObservableCollection <DepartmentDto>(departemnts); var employees = await _employeeApiService.GetAvailable(); EmployeeList = new ObservableCollection <EmployeeDto>(employees); } catch (Exception e) { _loggingService.LogFatal("Error during initalization!", e); _dialogService.ShowError(e.Message); } finally { IsLoading = false; } }
/// <summary> /// Loads data from the server /// </summary> protected override async Task InitializeAsync() { try { await ReloadList(); } catch (Exception e) { _loggingService.LogError($"Error during {typeof(T).ToString()} Lookup List initialization", e); _dialogService.ShowError(e.Message); } finally { IsLoading = false; } }
protected async override Task InitializeAsync() { try { IsLoading = true; var departments = await _departmentApiService.GetAvailable(); if (departments != null) { Departments = new ObservableCollection <DepartmentDto>(departments); } else { Departments = new ObservableCollection <DepartmentDto>(); } var sections = await _sectionApiService.GetAvailable(); if (sections != null) { Sections = new ObservableCollection <SectionDto>(sections); } else { Sections = new ObservableCollection <SectionDto>(); } if (_navigationService.Parameter != null) { if (_navigationService.Parameter is EmployeeDto param) { Employee.Value = param.Copy(); SelectedDepartment = Employee.Value.Department; RaisePropertyChanged(() => Employee); } } } catch (Exception e) { _loggingService.LogFatal("Error during initialization of Employee list!", 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; } }
protected override async Task InitializeAsync() { try { IsLoading = true; var itemNatureList = await _itemNatureApiService.GetAvailable(); if (itemNatureList == null) { throw new Exception("Hiba az eszköz jellegek lekérése során!"); } ItemNatures = new ObservableCollection <ItemNatureDto>(itemNatureList); var itemTypeList = await _itemTypeApiService.GetAvailable(); if (itemTypeList == null) { throw new Exception("Hiba az eszköz típusok lekérése során!"); } ItemTypes = new ObservableCollection <ItemTypeDto>(itemTypeList); var itemStateList = await _itemStateApiService.GetAvailable(); if (itemStateList == null) { throw new Exception("Hiba az eszköz állapotok lekérése során!"); } ItemStates = new ObservableCollection <ItemStateDto>(itemStateList); var buildingList = await _buildingApiService.GetAvailable(); if (buildingList == null) { throw new Exception("Hiba az épületek lekérése során!"); } Buildings = new ObservableCollection <BuildingDto>(buildingList); var floorList = await _floorApiService.GetAvailable(); if (floorList == null) { throw new Exception("Hiba az emeletek lekérése során!"); } Floors = new ObservableCollection <FloorDto>(floorList); var departmentList = await _departmentApiService.GetAvailable(); if (departmentList == null) { throw new Exception("Hiba az emeletek lekérése során!"); } Departments = new ObservableCollection <DepartmentDto>(departmentList); var sectionList = await _sectionApiService.GetAvailable(); if (sectionList == null) { throw new Exception("Hiba az emeletek lekérése során!"); } Sections = new ObservableCollection <SectionDto>(sectionList); var employeeList = await _employeeApiService.GetAvailable(); if (employeeList == null) { throw new Exception("Hiba az alkalmazottak lekérése során!"); } Employees = new ObservableCollection <EmployeeDto>(employeeList); } catch (Exception e) { _loggingService.LogError("Error during Initialization", e); _dialogService.ShowError(e.Message); } finally { IsLoading = false; } }