private async void OnHelperSearch(object sender, EventArgs e) { if (!string.IsNullOrEmpty(entrySearch.Text)) { listView.IsVisible = false; listView.SelectedItem = null; string selectedLoc = entrySearch.Text; //selectedLoc = selectedLoc.Split(',')[0]; var loc = selectedPrediction.Where(x => x.Description == selectedLoc).FirstOrDefault(); selectedPlace = await Places.GetPlace(loc.Place_ID, Constants.googlePlaceApiKey); HelpersServices helpersServices = new HelpersServices(); var h = await helpersServices.GetHelpersList(0, selectedService.Id, selectedScope.Id, selectedPlace.Latitude, selectedPlace.Longitude); if (filteredLocationType != '\0') { h = h.Where(x => x.LocationType.Equals(filteredLocationType)); } if (h != null && h.Count() != 0) { helpersViewModel.SetLocationOnMap(new ObservableCollection <HelperHomeModel>(h)); } } }
public async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { RegisterUserModel user = App.Database.GetLoggedUser(); HelpersServices helpersServices = new HelpersServices(); var myNetwork = await helpersServices.GetMyNetworks(user.Id); var n = myNetwork.Data; for (int i = 0; i < n.Count(); i++) { MyNetworkModel h = n.ElementAt(i); // if (h.Service != null && h.Service.Count() != 0) { //HService hserv = h.Service.Where(x => x.ServiceName == "ChildCare").FirstOrDefault(); //if (hserv == null) //{ // hserv = h.Service.ElementAt(h.Service.Count() - 1); // h.ServiceName = hserv.ServiceName; // if (hserv.price.Daily) // h.ServicePriceLabel = "from $" + hserv.price.Min.Remove(hserv.price.Min.IndexOf(".")) + "-$" + hserv.price.Max.Remove(hserv.price.Max.IndexOf(".")) + "/Day"; // else if (hserv.price.Monthly) // h.ServicePriceLabel = "from $" + hserv.price.Min.Remove(hserv.price.Min.IndexOf(".")) + "-$" + hserv.price.Max.Remove(hserv.price.Max.IndexOf(".")) + "/Month"; // else if (hserv.price.Hours) // h.ServicePriceLabel = "from $" + hserv.price.Min.Remove(hserv.price.Min.IndexOf(".")) + "-$" + hserv.price.Max.Remove(hserv.price.Max.IndexOf(".")) + "/Hour"; // if (hserv.Location != null && hserv.Location.Count() > 0) // h.ServiceLocationName = hserv.Location.ElementAt(0).LocationName; //if (h.NoOfRatingUserCount == null) //{ // h.AverageRatingCount = "(0)"; //} //else //{ h.AverageRatingCount = h.Rating.ToString() + " (" + h.NoOfRatingUserCount.ToString() + ")"; //} if (h.Status) { h.bgcolor = "#32BDA0"; h.textcolor = "#FFFFFF"; h.helperStatus = "Available"; } else { h.bgcolor = "#EAE9E9"; h.textcolor = "#000000"; h.helperStatus = "Not Available"; } n.Select(x => x.UserName == h.UserName ? h : x); } } MyNetworkList = new ObservableCollection <MyNetworkModel>(n); //aiFindHelper.IsRunning = false; } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private async void OnClickScopeFilter(object sender, EventArgs e) { aiFindHelper.IsRunning = true; if (selectedService != null && selectedService.Id != 0) { IList <ScopeModel> scopeAsync = (await new Utilities().GetScpoesAsync(selectedService.Id)); var scopesName = scopeAsync.Select(x => x.ScopeName); if (scopesName != null) { string filteredScope = await DisplayActionSheet("Select Scope", "Cancel", null, scopesName.ToArray()); if (mapHelper.IsVisible) { selectedScope = scopeAsync.Where(x => x.ScopeName == filteredScope).FirstOrDefault(); if (selectedScope != null) { HelpersServices helpersServices = new HelpersServices(); //var h = await helpersServices.GetHelpersList(0, selectedService.Id, selectedScope.Id); IEnumerable <HelperHomeModel> h = new List <HelperHomeModel>(); if (selectedPlace != null) { h = await helpersServices.GetHelpersList(0, selectedService.Id, selectedScope.Id, selectedPlace.Latitude, selectedPlace.Longitude); } else { h = await helpersServices.GetHelpersList(0, selectedService.Id, selectedScope.Id); } if (h != null) { if (filteredLocationType != '\0') { h = h.Where(x => x.LocationType.Equals(filteredLocationType)); } if (h != null) { mapHelper.helperList = h.ToList(); //var h = helpersViewModel.helperHomeFilterList.Where(x => x.LocationType == filteredLocationType); helpersViewModel.helperHomeFilterList = new ObservableCollection <HelperHomeModel>(h); helpersViewModel.SetLocationOnMap(helpersViewModel.helperHomeFilterList); } else { await DisplayAlert("", "No Helper found.", "OK"); } } else { await DisplayAlert("", "No Helper found.", "OK"); } lblScopeFilter.Text = filteredScope; } } else { } /* * var filteredList = helpersViewModel.helperHomeList.Where(x => x.Servicename == filteredService); * helpersViewModel.SetLocationOnMap(new ObservableCollection<HelperHomeModel>(filteredList)); */ } } else { await DisplayAlert("", "Please select service", "Ok"); } aiFindHelper.IsRunning = false; }
// string filteredSortBy = ""; private async void OnClickServiceFilter(object sender, EventArgs e) { aiFindHelper.IsRunning = true; IList <ServiceModel> servicesAsync = (await new Utilities().GetServicesAsync()); var servicesName = servicesAsync.Select(x => x.ServiceName); if (servicesName != null) { string filteredService = await DisplayActionSheet("Select service", "Cancel", null, servicesName.ToArray()); if (!filteredService.Equals("Cancel")) { #region reset scope filter lblScopeFilter.Text = "Scope"; selectedScope = new ScopeModel(); #endregion //if (mapHelper.IsVisible) //{ selectedService = servicesAsync.Where(x => x.ServiceName == filteredService).FirstOrDefault(); if (selectedService != null) { #region Update list on map HelpersServices helpersServices = new HelpersServices(); IEnumerable <HelperHomeModel> h = new List <HelperHomeModel>(); if (selectedPlace != null) { h = await helpersServices.GetHelpersList(0, selectedService.Id, 0, selectedPlace.Latitude, selectedPlace.Longitude); } else { h = await helpersServices.GetHelpersList(0, selectedService.Id); } if (h != null) { if (filteredLocationType != '\0') { h = h.Where(x => x.LocationType.Equals(filteredLocationType)); } if (h != null) { mapHelper.helperList = h.ToList(); //var h = helpersViewModel.helperHomeFilterList.Where(x => x.LocationType == filteredLocationType); helpersViewModel.helperHomeFilterList = new ObservableCollection <HelperHomeModel>(h); helpersViewModel.SetLocationOnMap(helpersViewModel.helperHomeFilterList); } else { await DisplayAlert("", "No Helper found.", "OK"); } } else { await DisplayAlert("", "No Helper found.", "OK"); } #endregion #region Update full list helpersViewModel.helperFullFilterList = new ObservableCollection <HelperHome>(); foreach (HelperHome hh in helpersViewModel.HelperFullList) { var hServices = hh.Service.Where(x => x.ServiceName == selectedService.ServiceName); if (hServices != null && filteredLocationType != '\0') { hServices = hServices.Where(x => x.LocationType == filteredLocationType.ToString()); } if (hServices.Count() != 0) { helpersViewModel.helperFullFilterList.Add(hh); } } lvFullHelpa.ItemsSource = helpersViewModel.helperFullFilterList; lblHelperFullCount.Text = helpersViewModel.helperFullFilterList.Count + " Helpers found"; #endregion lblServiceFilter.Text = filteredService; } //} //else //{ // selectedService = servicesAsync.Where(x => x.ServiceName == filteredService).FirstOrDefault(); // if (selectedService != null) // { // //var hServices = helpersViewModel.HelperFullList.Select(x => x.Service); // helpersViewModel.helperFullFilterList = new ObservableCollection<HelperHome>(); // foreach (HelperHome h in helpersViewModel.HelperFullList) // { // var hServices = h.Service.Where(x => x.ServiceName == selectedService.ServiceName); // if (hServices != null && filteredLocationType != '\0') // hServices = hServices.Where(x => x.LocationType == filteredLocationType.ToString()); // if (hServices.Count() != 0) // helpersViewModel.helperFullFilterList.Add(h); // } // lblServiceFilter.Text = filteredService; // lvFullHelpa.ItemsSource = helpersViewModel.helperFullFilterList; // lblHelperFullCount.Text = helpersViewModel.helperFullFilterList.Count + " Helpers found"; // } } /* * var filteredList = helpersViewModel.helperHomeList.Where(x => x.HelpersInLocalties.ServiceName == filteredService); * helpersViewModel.SetLocationOnMap(new ObservableCollection<HelperHomeModel>(filteredList)); */ } aiFindHelper.IsRunning = false; }
async void ShowHelperFullList() { try { aiFindHelper.IsRunning = true; HHomeModel hService = new HHomeModel(); HelpersServices helpersServices = new HelpersServices(); RegisterUserModel loggedUser = App.Database.GetLoggedUser(); if (loggedUser == null) { hService = await helpersServices.GetAllHelpers(0); } else { hService = await helpersServices.GetAllHelpers(loggedUser.Id); } var hs = hService.Data; lblHelperFullCount.Text = hService.Total + " Helpers found"; for (int i = 0; i < hs.Count(); i++) { HelperHome h = hs.ElementAt(i); if (h.ProfilePicture == null) { h.ProfilePicture = "profile_default.png"; } if (h.BookMark) { h.BookmarkImage = "save_filled.png"; } else { h.BookmarkImage = "save.png"; } if (h.Service != null && h.Service.Count() != 0) { HService hserv = h.Service.Where(x => x.ServiceName == "ChildCare").FirstOrDefault(); if (hserv == null) { hserv = h.Service.ElementAt(h.Service.Count() - 1); h.ServiceName = hserv.ServiceName; if (hserv.price.Daily) { h.ServicePriceLabel = "from $" + hserv.price.Min.Remove(hserv.price.Min.IndexOf(".")) + "-$" + hserv.price.Max.Remove(hserv.price.Max.IndexOf(".")) + "/Day"; } else if (hserv.price.Monthly) { h.ServicePriceLabel = "from $" + hserv.price.Min.Remove(hserv.price.Min.IndexOf(".")) + "-$" + hserv.price.Max.Remove(hserv.price.Max.IndexOf(".")) + "/Month"; } else if (hserv.price.Hours) { h.ServicePriceLabel = "from $" + hserv.price.Min.Remove(hserv.price.Min.IndexOf(".")) + "-$" + hserv.price.Max.Remove(hserv.price.Max.IndexOf(".")) + "/Hour"; } if (hserv.Location != null && hserv.Location.Count() > 0) { h.ServiceLocationName = hserv.Location.ElementAt(0).LocationName; } /* source.Select(element => element == oldValue ? newValue : element) */ if (h.AverageRatingCount == null) { h.AverageRatingCount = "(0)"; } else { h.AverageRatingCount = h.AverageRating + " (" + h.AverageRatingCount + ")"; } if (h.Status) { h.bgcolor = "#32BDA0"; h.textcolor = "#FFFFFF"; h.helperStatus = "Available"; } else { h.bgcolor = "#EAE9E9"; h.textcolor = "#000000"; h.helperStatus = "Not Available"; } if (h.AverageRating == null) { h.AverageRating = "0"; } hs.Select(x => x.Name == h.Name ? h : x); } } } helpersViewModel.HelperFullList = new ObservableCollection <HelperHome>(hs); lvFullHelpa.ItemsSource = helpersViewModel.HelperFullList; //lblHelperCount.Text = hs.Count() + " Helpers found in " + selectedHelpersInCluster.LocationName; aiFindHelper.IsRunning = false; } catch (Exception e) { Console.Write(e.StackTrace); aiFindHelper.IsRunning = false; } }
async void ShowHelperHalfList(string selectedCluster) { try { rlHalfView.IsVisible = true; var selectedHelpersInCluster = helpersViewModel.helperHomeList.Where(h => h.LocationName == (selectedCluster)).FirstOrDefault(); mapHelper.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(selectedHelpersInCluster.Latitude - 0.0055, selectedHelpersInCluster.Longitude), Distance.FromKilometers(1))); IEnumerable <HelperHome> hs = new List <HelperHome>(); HelpersServices helpersServices = new HelpersServices(); RegisterUserModel loggedUser = App.Database.GetLoggedUser(); if (loggedUser == null) { hs = await helpersServices.GetHelpersInLocation(selectedHelpersInCluster.Latitude, selectedHelpersInCluster.Longitude, 0); } else { hs = await helpersServices.GetHelpersInLocation(selectedHelpersInCluster.Latitude, selectedHelpersInCluster.Longitude, loggedUser.Id); } // var hs = await helpersServices.GetHelpersInLocation(selectedHelpersInCluster.Latitude, selectedHelpersInCluster.Longitude, 0); for (int i = 0; i < hs.Count(); i++) { HelperHome h = hs.ElementAt(i); if (h.BookMark) { h.BookmarkImage = "save_filled.png"; } else { h.BookmarkImage = "save.png"; } if (h.Service != null && h.Service.Count() != 0) { HService hserv = h.Service.Where(x => x.ServiceName == "ChildCare").FirstOrDefault(); if (hserv == null) { hserv = h.Service.ElementAt(h.Service.Count() - 1); h.ServiceName = hserv.ServiceName; if (hserv.price.Daily) { h.ServicePriceLabel = "from $" + hserv.price.Min.Remove(hserv.price.Min.IndexOf(".")) + "-$" + hserv.price.Max.Remove(hserv.price.Max.IndexOf(".")) + "/Day"; } else if (hserv.price.Monthly) { h.ServicePriceLabel = "from $" + hserv.price.Min.Remove(hserv.price.Min.IndexOf(".")) + "-$" + hserv.price.Max.Remove(hserv.price.Max.IndexOf(".")) + "/Month"; } else if (hserv.price.Hours) { h.ServicePriceLabel = "from $" + hserv.price.Min.Remove(hserv.price.Min.IndexOf(".")) + "-$" + hserv.price.Max.Remove(hserv.price.Max.IndexOf(".")) + "/Hour"; } if (hserv.Location != null && hserv.Location.Count() > 0) { h.ServiceLocationName = hserv.Location.ElementAt(0).LocationName; } /* source.Select(element => element == oldValue ? newValue : element) */ if (h.AverageRatingCount == null) { h.AverageRatingCount = "(0)"; } else { h.AverageRatingCount = "(" + h.AverageRatingCount + ")"; } if (h.Status) { h.bgcolor = "#32BDA0"; h.textcolor = "#FFFFFF"; h.helperStatus = "Available"; } else { h.bgcolor = "#EAE9E9"; h.textcolor = "#000000"; h.helperStatus = "Not Available"; } hs.Select(x => x.Name == h.Name ? h : x); } } } helpersViewModel.HelperHalfList = new ObservableCollection <HelperHome>(hs); lvHalfHelpa.ItemsSource = helpersViewModel.HelperHalfList; lblHelperCount.Text = hs.Count() + " Helpers found in " + selectedHelpersInCluster.LocationName; } catch (Exception e) { Console.Write(e.StackTrace); } }
public async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { var user = App.Database.GetLoggedUser(); #region get saved user HelpersServices helpersServices = new HelpersServices(); var savedUser = await helpersServices.GetSavedUsers(user.Id); SavedUserCount = savedUser.Total; var n = savedUser.Data; for (int i = 0; i < n.Count(); i++) { MyNetworkModel h = n.ElementAt(i); h.AverageRatingCount = h.Rating.ToString() + " (" + h.NoOfRatingUserCount.ToString() + ")"; if (h.Status) { h.bgcolor = "#32BDA0"; h.textcolor = "#FFFFFF"; h.helperStatus = "Available"; } else { h.bgcolor = "#EAE9E9"; h.textcolor = "#000000"; h.helperStatus = "Not Available"; } n.Select(x => x.UserName == h.UserName ? h : x); } SavedUserList = new ObservableCollection <MyNetworkModel>(n); #endregion #region get saved job posts JobServices jobServices = new JobServices(); var js = await jobServices.GetSavedJobs(user.Id); SavedJobsCount = js.Total; for (int i = 0; i < js.Data.Count(); i++) { JobsHome j = js.Data.ElementAt(i); if (j != null) { if (j.JobType == "N") { j.JobType = "Normal"; j.JobBgColor = "#289EF5"; j.JobTextColor = "#FFFFFF"; } else if (j.JobType == "U") { j.JobType = "Urgent"; j.JobBgColor = "#F63D38"; j.JobTextColor = "#FFFFFF"; } else { j.JobType = "Sponsored"; j.JobBgColor = "#FCDC55"; j.JobTextColor = "#000000"; } } if (j.Location != null && j.Location.Count() > 0) { j.JobLocationName = j.Location.ElementAt(0).LocationName; } if (j.IsDaily) { j.JobPriceLabel = "From $" + j.MinDailyPrice.Remove(j.MinDailyPrice.IndexOf(".")) + "-$" + j.MaxDailyPrice.Remove(j.MaxDailyPrice.IndexOf(".")) + "/Day"; } else if (j.IsMonthly) { j.JobPriceLabel = "From $" + j.MinMonthlyPrice.Remove(j.MinMonthlyPrice.IndexOf(".")) + "-$" + j.MaxMonthlyPrice.Remove(j.MaxMonthlyPrice.IndexOf(".")) + "/Month"; } else if (j.IsHourly) { j.JobPriceLabel = "From $" + j.MinHourlyPrice.Remove(j.MinHourlyPrice.IndexOf(".")) + "-$" + j.MaxHourlyPrice.Remove(j.MaxHourlyPrice.IndexOf(".")) + "/Hour"; } j.createDate = j.CreateDate.Substring(0, 10); js.Data.Select(x => x.JobId == j.JobId ? j : x); } SavedJobPostsList = new ObservableCollection <JobsHome>(js.Data); #endregion //aiFindHelper.IsRunning = false; } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { HelperFullList = new ObservableCollection <HelperHome>(); HelperHalfList = new ObservableCollection <HelperHome>(); activityIndicator.IsRunning = true; HelpersServices helpersServices = new HelpersServices(); var h = await helpersServices.GetHelpersList(); if (h != null && (h.Count() > 0)) { mapHelper.helperList = h.ToList(); helperHomeList = new ObservableCollection <HelperHomeModel>(h.ToList()); helperHomeFilterList = helperHomeList; } //var HelperList = new ObservableCollection<HelperHome>(((new HelpersServices()).GetHelpersList(2000000, 28.4514279, 77.0704678)).Result.First().HelpersInLocalties); //for(int i=0;i<helperHomeList.Count;i++) //{ // helperHomeList.ElementAt(i).LocationType = 'S'; //} #region Check Location Permission try { var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location); if (status != PermissionStatus.Granted) { if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Location)) { await helperInstance.DisplayAlert("Need location", "Helpa need that location", "OK"); return; } //var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Location); await DependencyService.Get <IPermissionServices>().GetPermission(helperInstance); //if (results.ContainsKey(Permission.Location)) // status = results[Permission.Location]; } if (status == PermissionStatus.Granted) { await DependencyService.Get <IPermissionServices>().CheckAndTurnOnGPS(helperInstance); SetLocationOnMap(helperHomeList); } else if (status != PermissionStatus.Unknown) { await helperInstance.DisplayAlert("Location Denied", "Please allow location permission to get your location for Helpa app in Device setting", "OK"); } } catch (Exception ex) { await helperInstance.DisplayAlert("Error", ex.Message, "OK"); } /**********************************************************************/ //var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location); //if (status == PermissionStatus.Granted) /*{ * ProgressBar pb = new ProgressBar(); * * activityIndicator.IsRunning = true; * * //var position = await CrossGeolocator.Current.GetPositionAsync(); * var position = helperHomeList.ElementAt(0); * mapHelper.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(position.Latitude, position.Longitude), Distance.FromKilometers(1))); * mapHelper.IsShowingUser = true; * mapHelper.MapType = MapType.Street; * * activityIndicator.IsRunning = false; * #region Call api to get data from server * // var helpers = await DataStore.GetHelpersList(10000, 28.4514279, 77.0704678); * // var helpers = await (new HelpersServices()).GetHelpersList(2000000, position.Latitude, position.Longitude); * // HelperList = new ObservableCollection<HelperHome>(helpers.First().HelpersInLocalties); #endregion * }*/ #endregion } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }