public async Task BindData(bool reloadData = false) { if (IsLoadingData) { return; } try { IsLoadingData = true; if (reloadData || JobListHelper.SavedJobsModel == null || JobListHelper.SavedJobsModel.Count() == 0) { JobListHelper.SavedJobsModel = new List <JobDataModel>(); await JobsListResolver.LoadSavedJobs(); } JobSearchBindcast = new ObservableCollection <JobDataModel>(JobListHelper.SavedJobsModel); } catch (Exception ex) { var logged = new LoggedException.LoggedException("Error in savedjobviewmodel", ex); await logged.LoggAPI(); } finally { IsLoadingData = false; JobsCounterHelper.NoOFSavedJobs = JobSearchBindcast.Count(); Savedcounter = JobsCounterHelper.NoOFSavedJobsText(); } }
public async Task BindData(bool reloadData = false, bool clearSerach = false) { if (clearSerach) { ZipCode = null; enddate = DateTime.Now; startdate = DateTime.Now; minhourrate = 0; maxhourate = 0; //JobListHelper.IsSearching = false; } if (IsLoadingData) { return; } //if (diff.TotalSeconds <= 2) //return; JobListHelper.LastScrollTime = DateTime.Now; LoadingIndicatorHelper.AddProgressDisplay(); IsLoadingData = true; if (reloadData || JobListHelper.SearchJobsModel == null || JobListHelper.SearchJobsModel.result == null || JobListHelper.SearchJobsModel.result.Count() == 0) { await JobsListResolver.LoadJobsListSearch(searchtext, ZipCode, startdate, enddate, (int)minhourvar, (int)maxhourate); } try { JobSearchBindcast = new ObservableCollection <JobDataModel>(JobListHelper.SearchJobsModel.result); } catch (Exception ex) { var logged = new LoggedException.LoggedException("Error in jobsearchviewmodel", ex); await logged.LoggAPI(); } finally { JobsCounterHelper.NoOfCurrentJobs = JobSearchBindcast.Count(); CurrentCounter = JobsCounterHelper.NoOfCurrentJobsText(); Applied = JobsCounterHelper.NoOfAppliedJobsText(); Saved = JobsCounterHelper.NoOFSavedJobsText(); IsLoadingData = false; } LoadingIndicatorHelper.HideIndicator(); }
public AppliedJobsViewModel() { Appliedcounter = JobsCounterHelper.NoOfAppliedJobsText(); jobsearchList = new List <JobDataModel>(); JobSearchBindcast = new ObservableCollection <JobDataModel>(); if (!CrossConnectivity.Current.IsConnected) { InternetOrServeHelper.ShowCheckInternet(); } else { BindData(true); } }
public JobSearchviewModel() { CurrentCounter = JobsCounterHelper.NoOfCurrentJobsText(); JobSearchBindcast = new ObservableCollection <JobDataModel>(); if (!CrossConnectivity.Current.IsConnected) { InternetOrServeHelper.ShowCheckInternet(); } else { BindData(); } MyProperty = new jobsearchcasted(); minhourrate = new double(); maxhourate = new double(); }
private async void imagetaps_Tapped(object sender, EventArgs e) { try { //To be deleted int oldCount = JobsCounterHelper.NoOFSavedJobs; Unsavedjob apidelete = new Unsavedjob(); JobSavedRestClient apisaved = new JobSavedRestClient(); var image = (Image)sender; var id = (TappedEventArgs)e; var jobIsSaved = JobListHelper.SearchJobsModel.result.Any(d => d.Id == id.Parameter.ToString() && d.isSaved == true); var titlejob = JobListHelper.SearchJobsModel.result.Where(i => i.Id == id.Parameter.ToString()).First(); if (jobIsSaved) { var Delete = await DisplayAlert("Confirmation Message", AlertMessages.unsavedjob + " " + titlejob.JobType + ") ?", "Yes", "Cancel"); if (Delete == true) { try { var unsaved = await apidelete.deleteData(id.Parameter.ToString(), URLConfig.Unsavedjob); if (unsaved) { //image.Source = "emptystar"; var job = JobListHelper.SearchJobsModel.result.Where(i => i.Id == id.Parameter.ToString()).First(); var Saved_job = JobListHelper.SavedJobsModel.Where(i => i.Id == id.Parameter.ToString()).First(); job.isSaved = false; job.Image = "emptystar"; var index = JobListHelper.SearchJobsModel.result.IndexOf(job); var Saved_index = JobListHelper.SavedJobsModel.IndexOf(Saved_job); var searchObsIndex = ((JobSearchviewModel)namegrid.BindingContext).JobSearchBindcast.IndexOf(job); if (index != -1 && Saved_index != -1 && searchObsIndex != -1) { //we don't need to call the api each time I remove the saved Job // await((savedjobsViewModel)SavedJobsLayout.BindingContext).BindData(true); JobListHelper.SearchJobsModel.result[index] = job; JobListHelper.SavedJobsModel[Saved_index] = Saved_job; ((JobSearchviewModel)namegrid.BindingContext).JobSearchBindcast[searchObsIndex] = job; ((savedjobsViewModel)SavedJobsLayout.BindingContext).JobSearchBindcast.Remove(Saved_job); JobsCounterHelper.NoOFSavedJobs = ((savedjobsViewModel)SavedJobsLayout.BindingContext).JobSearchBindcast.Count(); JobsCounterHelper._noOFSavedJobsText = JobsCounterHelper.NoOFSavedJobsText(); ((JobSearchviewModel)namegrid.BindingContext).Saved = JobsCounterHelper.NoOFSavedJobsText(); } } } catch (Exception ex) { var logged = new LoggedException.LoggedException("Error while trying to save job", ex); await logged.LoggAPI(); } } } else { var answer = await DisplayAlert("Confirmation Message", AlertMessages.savedjob + " " + titlejob.JobType + ") ?", "Yes", "Cancel"); if (answer == true) { try { var succed = await apisaved.PostSaveJob(URLConfig.SaveJobsUrl, id.Parameter.ToString()); if (succed) { //image.Source = "star"; var job = JobListHelper.SearchJobsModel.result.Where(i => i.Id == id.Parameter.ToString()).First(); job.Image = "star"; job.isSaved = true; var index = JobListHelper.SearchJobsModel.result.IndexOf(job); if (index != -1) { await((savedjobsViewModel)SavedJobsLayout.BindingContext).BindData(true); JobListHelper.SearchJobsModel.result[index] = job; JobsCounterHelper._noOFSavedJobsText = JobsCounterHelper.NoOFSavedJobsText(); ((JobSearchviewModel)namegrid.BindingContext).Saved = JobsCounterHelper.NoOFSavedJobsText(); } } } catch (Exception ex) { var logged = new LoggedException.LoggedException("Error while trying to save job", ex); await logged.LoggAPI(); } } } } catch (Exception ex) { var logged = new LoggedException.LoggedException("Error in joblistingtapedimage.xaml.cs", ex); await logged.LoggAPI(); } }
protected override async void OnAppearing() { try { // await LoadJobs(); //JobListHelper.ExpireTimerEnabled = false; await Task.Yield(); LoadingIndicatorHelper.Intialize(this); if (JobListHelper.IsApplied) { //Refresh Applied List int oldCount = JobsCounterHelper.NoOfAppliedJobs; await((AppliedJobsViewModel)AppliedJobsLayout.BindingContext).BindData(true); int newCount = oldCount + 1; JobsCounterHelper.NoOfAppliedJobs = newCount; JobsCounterHelper._noOfAppliedJobsText = JobsCounterHelper.NoOfAppliedJobsText(); ((JobSearchviewModel)namegrid.BindingContext).Applied = JobsCounterHelper.NoOfAppliedJobsText(); ChangeToApplied(null, null); JobListHelper.IsSearching = false; JobListHelper.IsSaved = false; } //else if (JobListHelper.IsSearching) //{ // JobListHelper.IsApplied = false; // JobLissearchtaptHelper.IsSaved = false; // .BackgroundColor = Color.FromHex("#87c8ee"); // isearchtap.Source = "Magnifier.png"; // searchtapLabel.TextColor = Color.White; // MyJobstap.BackgroundColor = Color.White; // iMyJobstap.Source = "MyJobsi.png"; // MyJobstapLabel.TextColor = Color.DimGray; // ChangeToCurrent(null, null); //} else if (JobListHelper.IsSaved) { JobListHelper.IsSearching = false; JobListHelper.IsSaved = false; ChangeToSaved(null, null); } if (constants.SearchView) { constants.SearchView = false; //if (FilterGrid.IsVisible) //{ // FilterGrid.FadeTo(0); // FilterGrid.IsVisible = false; // searchtap.BackgroundColor = Color.White; // isearchtap.Source = "Magnifier.png"; // searchtapLabel.TextColor = Color.DimGray; // //gray color //} //else //{ FilterGrid.IsVisible = true; CurrentJobsLayout.IsVisible = false; namegrid.IsVisible = false; FilterGrid.FadeTo(1); searchtap.BackgroundColor = Color.FromHex("#87c8ee"); isearchtap.Source = "Magnifieri.png"; searchtapLabel.TextColor = Color.White; MyJobstap.BackgroundColor = Color.White; iMyJobstap.Source = "MyJobs.png"; MyJobstapLabel.TextColor = Color.DimGray; //} } else { MyJobstap.BackgroundColor = Color.FromHex("#87c8ee"); iMyJobstap.Source = "MyJobsi.png"; MyJobstapLabel.TextColor = Color.White; CurrentJobsLayout.IsVisible = true; } } catch (Exception ex) { var logged = new LoggedException.LoggedException("error in joblisting.xaml.cs", ex); await logged.LoggAPI(); } }