private async void SelectedLocations_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { try { SelectedLocations.CollectionChanged -= SelectedLocations_CollectionChanged; if (e.NewItems != null) { foreach (Location newItem in e.NewItems) { SelectedLocations.Add(newItem); await _settingsService.AddLocationAsync(newItem); } } if (e.OldItems != null) { foreach (Location oldtem in e.OldItems) { SelectedLocations.Remove(oldtem); await _settingsService.RemoveLocationAsync(oldtem); } } SelectedLocations.CollectionChanged += SelectedLocations_CollectionChanged; } catch (Exception exeption) { _loggingService?.WriteError(exeption); } }
public void ReloadClicked() { FirstName = ""; LastName = ""; SelectedCountry = ""; LocationName = ""; ChildID = ""; SearchResult = ""; SearchErrorVisible = false; SelectAll = false; DOBIsValid = false; EnrollmentDateIsValid = false; IsTableBottomLineVisible = false; SearchErrorVisible = false; SelectedLocations.Clear(); SelectedLocations = new List <string>(); foreach (var item in LocationsObservableCollection) { if (item.IsSelected) { item.IsSelected = false; } } SearchClicked(null, null); return; }
private string GetCurrencyString() { string result = ""; result += (SelectedLocations.Find(l => String.Equals(l.Name, "England", StringComparison.Ordinal)) != null) ? "£" : "n"; result += (SelectedLocations.Find(l => String.Equals(l.Name, "America", StringComparison.Ordinal)) != null) ? "$" : "n"; result += (SelectedLocations.Find(l => String.Equals(l.Name, "Italy", StringComparison.Ordinal)) != null) ? "e" : "n"; return(result); }
public void BeginSelectLocation() { SelectedLocations.Clear(); IsInBrowseMode = false; IsInEditMode = false; IsInSelectMode = true; SelectionMode = SelectionMode.Multiple; IsItemClickEnabled = false; }
private void OnNotSelectedLocationDoubleClickCommand() { var location = SelectedNotSelectedLocation; if (location == null) { return; } NotSelectedLocations.Remove(location); SelectedLocations.Add(location); RaisePropertyChanged(() => SelectedLocations); RaisePropertyChanged(() => NotSelectedLocations); }
/// <summary> /// sets the returnparameter before closing /// </summary> /// <param name="window"></param> private void OnApplyCommand(Window window) { ReturnParameter = Parameter; ReturnParameter.Buildings = SelectedBuildings.ToList(); ReturnParameter.Departments = SelectedDepartments.ToList(); ReturnParameter.ItemStates = SelectedItemStates.ToList(); ReturnParameter.ItemNatures = SelectedItemNatures.ToList(); ReturnParameter.ItemTypes = SelectedItemTypes.ToList(); ReturnParameter.Locations = SelectedLocations.ToList(); ReturnParameter.Sections = SelectedSections.ToList(); ReturnParameter.Floors = SelectedFloors.ToList(); window.DialogResult = true; window.Close(); }
private void PopulateSelectedLocation() { var selectedLocation = SelectedLocations.LastOrDefault(); if (selectedLocation == null) { return; } SelectedLocation = new Location { Id = selectedLocation.Id, Name = selectedLocation.Name }; }
private void InitializeLocations() { SelectedLocations.CollectionChanged -= SelectedLocations_CollectionChanged; SelectedLocations.Clear(); foreach (var location in User.Locations) { if (_settingsService.Settings.Locations.Any(l => l.Id == location.Id)) { SelectedLocations.Add(location); } } SelectedLocations.CollectionChanged += SelectedLocations_CollectionChanged; }
public async Task RemoveSelectedLocations() { if (SelectedLocations.Count == 0) { await _dialogService.ShowAsync("Please select at least one location."); return; } var response = await _dialogService.ShowConfirmationAsync("Do you really want to remove the selected locations?"); if (response == ConfirmationAnswer.Cancel) { return; } IsBusy = true; var selectedLocations = SelectedLocations.ToList(); foreach (var selLoc in selectedLocations) { var snapshots = await _locationSnapshotDataService.GetSnapshotsByLocationIdAsync(selLoc.Id); var deletionTasks = snapshots.Select(async _ => { await _locationSnapshotDataService.RemoveSnapshotAsync(_.Id); await _pictureService.RemoveSnapshotContentAsync(_); }); await Task.WhenAll(deletionTasks); var removedLocation = await _locationDataService.RemoveLocationAsync(selLoc.Id); Locations.Remove(Locations.First(_ => _.Id == removedLocation.Id)); } ; SetDefaultView(); IsBusy = 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; } }
public async void SearchClicked(string dob, string enrollmentDate) { var searchChildRecords = new List <ChildRecordsNewAssessment>(); var isMorethan1000 = false; await LoadChildRecordsFromDBAsync(); if (!string.IsNullOrEmpty(FirstName) || !string.IsNullOrEmpty(LastName) || (SelectedLocations != null && SelectedLocations.Any()) || !string.IsNullOrEmpty(dob) || !string.IsNullOrEmpty(enrollmentDate) || !string.IsNullOrEmpty(ChildID)) { IEnumerable <ChildRecordsNewAssessment> query = ChildTestRecords; if (!string.IsNullOrEmpty(FirstName)) { query = query.Where(p => !string.IsNullOrEmpty(p.FirstName) && p.FirstName.ToLower().Contains(FirstName.ToLower())); } if (!string.IsNullOrEmpty(LastName)) { query = query.Where(p => !string.IsNullOrEmpty(p.LastName) && p.LastName.ToLower().Contains(LastName.ToLower())); } if (!string.IsNullOrEmpty(ChildID)) { query = query.Where(p => !string.IsNullOrEmpty(p.ChildID) && p.ChildID.ToLower().Contains(ChildID.ToLower())); } if (!string.IsNullOrEmpty(dob)) { query = query.Where(p => !string.IsNullOrEmpty(p.DOB) && p.DOB == dob); } if (!string.IsNullOrEmpty(enrollmentDate)) { query = query.Where(p => !string.IsNullOrEmpty(p.Enrollment) && p.Enrollment == enrollmentDate); } if (SelectedLocations.Count > 0) { query = query.Where(p => !string.IsNullOrEmpty(p.Location) && SelectedLocations.Contains(p.Location)); } searchChildRecords = new List <ChildRecordsNewAssessment>(query); } else { searchChildRecords = ChildTestRecords; } if (!searchChildRecords.Any()) { SearchResult = ErrorMessages.RecordMatchesFoundMessage; SearchErrorColor = Color.Red; SearchErrorVisible = true; } else { SearchResult = string.Format(ErrorMessages.RecordsFoundMessage, searchChildRecords.Count(), searchChildRecords.Count() == 1 ? "Match" : "Matches"); SearchErrorColor = Color.Black; SearchErrorVisible = true; if (searchChildRecords.Count > 1000) { isMorethan1000 = true; SearchResult = ErrorMessages.SearchError; SearchErrorColor = Color.Red; SearchErrorVisible = true; } else if (searchChildRecords.Count > 5) { searchChildRecords[searchChildRecords.Count - 1].IsTableSepartorVisble = false; } else { searchChildRecords[searchChildRecords.Count - 1].IsTableSepartorVisble = true; IsTableBottomLineVisible = false; } if (SelectAll) { int index = 0; foreach (var record in searchChildRecords) { index++; } } } var list = searchChildRecords.OrderBy(a => a.LastName); var reorderedList = new List <ChildRecordsNewAssessment>(list); ChildTestRecords.Clear(); if (!isMorethan1000) { ChildTestRecords = reorderedList; } }
/// <summary> /// Fetch child records /// </summary> public async void GetChildRecords() { int addedBy; if (ChildRecords.Any()) { ChildRecords.Clear(); } var initialChildRecords = new List <ChildRecord>(); if (Application.Current.Properties.ContainsKey("UserID")) { var isSuccess = int.TryParse(Application.Current.Properties["UserID"].ToString(), out addedBy); if (isSuccess) { var childRecords = (_studentService.GetStudentsByOfflineID(addedBy)); var testRecords = (_clinicalTestFormService.GetStudentTestForms()).Where(x => x.FormStatus != "Not started").Select(x => x.LocalStudentId).ToList(); var filteredChildRecord = childRecords.FindAll(x => testRecords.Contains(x.OfflineStudentID)); foreach (var childRecord in filteredChildRecord) { if (childRecord.SelectedLocationId.HasValue && AllLocations != null && AllLocations.Any() && AllLocations.Where(p => p.IsEnabled).Any(p => p.LocationId == childRecord.SelectedLocationId.Value)) { string birthdate = (childRecord.Birthdate.Month < 10 ? "0" + childRecord.Birthdate.Month : childRecord.Birthdate.Month + "") + "/" + (childRecord.Birthdate.Day < 10 ? "0" + childRecord.Birthdate.Day : childRecord.Birthdate.Day + "") + "/" + childRecord.Birthdate.Year; initialChildRecords.Add(new ChildRecord() { Name = childRecord.FirstName + " " + childRecord.LastName, selected = false, Location = AllLocations != null && AllLocations.Any() && childRecord.SelectedLocationId != null ? AllLocations.FirstOrDefault(p => p.LocationId == childRecord.SelectedLocationId.Value)?.LocationName : "", LocationID = (childRecord.SelectedLocationId == null) ? 0 : Convert.ToInt32(childRecord.SelectedLocationId), OfflineStudentId = childRecord.OfflineStudentID, DOB = birthdate }); } } var list = initialChildRecords.OrderBy(a => a.LastName); initialChildRecords = new List <ChildRecord>(list); var searchChildRecords = new List <ChildRecord>(); IEnumerable <ChildRecord> query = initialChildRecords; if (SelectedLocations.Count > 0) { query = query.Where(p => !string.IsNullOrEmpty(p.Location) && SelectedLocations.Contains(p.Location)); } searchChildRecords = new List <ChildRecord>(query); foreach (var item in searchChildRecords) { ChildRecords.Add(item); } } } if (ChildRecords.Count == 0) { SelectedChild = "No results found"; IsChildRecordButtonEnabled = false; IsBatteryTypeButtonEnabled = false; } else { SelectedChild = null; } }