private async Task LoadPickers() { var apiCaller = new WebApi(); var departmentStrings = await apiCaller.PostAsync("Departments", null); _departmentList = JsonConvert.DeserializeObject <List <Department> >(departmentStrings); foreach (var item in _departmentList) { pDepartment.Items.Add(item.Name); } var departmentLocationsStrings = await apiCaller.PostAsync("DepartmentLocations", null); _departmentLocationsList = JsonConvert.DeserializeObject <List <DepartmentLocation> >(departmentLocationsStrings); var locationStrings = await apiCaller.PostAsync("Locations", null); _locationList = JsonConvert.DeserializeObject <List <Location> >(locationStrings); var assetGroupsStrings = await apiCaller.PostAsync("AssetGroups", null); _assetGroupsList = JsonConvert.DeserializeObject <List <AssetGroup> >(assetGroupsStrings); foreach (var item in _assetGroupsList) { pAssetGroup.Items.Add(item.Name); } var accountableStrings = await apiCaller.PostAsync("Employees", null); _accountableList = JsonConvert.DeserializeObject <List <Employee> >(accountableStrings); foreach (var item in _accountableList) { pAccountable.Items.Add(item.FirstName + " " + item.LastName); } }
private async Task LoadPickers() { pDepartment.Items.Clear(); pAssetGroups.Items.Clear(); pAssetGroups.Items.Add("No Filter"); pDepartment.Items.Add("No Filter"); var apiCaller = new WebApi(); var departmentStrings = await apiCaller.PostAsync("Departments", null); var departmentList = JsonConvert.DeserializeObject <List <Department> >(departmentStrings); foreach (var item in departmentList) { pDepartment.Items.Add(item.Name); } var assetGroupsStrings = await apiCaller.PostAsync("AssetGroups", null); var assetGroupsList = JsonConvert.DeserializeObject <List <AssetGroup> >(assetGroupsStrings); foreach (var item in assetGroupsList) { pAssetGroups.Items.Add(item.Name); } }
private async Task GetAssets() { var apiCaller = new WebApi(); var getAssetSN = await apiCaller.PostAsync("Assets/GetUniqueSNs", null); _uniqueSNs = JsonConvert.DeserializeObject <List <string> >(getAssetSN); }
private async Task LoadAssets() { var apiCaller = new WebApi(); var results = await apiCaller.PostAsync("Assets/GetCustomView", null); _assetList = JsonConvert.DeserializeObject <List <CustomListView> >(results); lvAssets.ItemsSource = _assetList; }
private async void btnSubmit_Clicked(object sender, EventArgs e) { var getDepartmentID = (from x in _departmentList where x.Name == pDepartment.SelectedItem.ToString() select x.ID).First(); var getLocationID = (from x in _locationList where x.Name == pLocation.SelectedItem.ToString() select x.ID).First(); var assetGroupID = (from x in _assetGroupsList where x.Name == pAssetGroup.SelectedItem.ToString() select x.ID).First(); var getDepartmentLocationID = (from x in _departmentLocationsList where x.DepartmentID == getDepartmentID && x.LocationID == getLocationID select x.ID).First(); var getEmployeeID = (from x in _accountableList where pAccountable.SelectedItem.ToString() == x.FirstName + " " + x.LastName select x.ID).First(); var newAsset = new Asset() { AssetSN = lblAssetSN.Text, WarrantyDate = dpExpired.Date, Description = editorDescription.Text, AssetName = entryAssetName.Text, AssetGroupID = assetGroupID, DepartmentLocationID = getDepartmentLocationID, EmployeeID = getEmployeeID }; var JsonData = JsonConvert.SerializeObject(newAsset); var apiCaller = new WebApi(); var response = await apiCaller.PostAsync("Assets/Create", JsonData); if (response == "\"Asset created successfully!\"") { await DisplayAlert("Asset Creation/Modifications", "Asset created successfully!", "Ok"); await Navigation.PopAsync(); } }