Exemple #1
0
        public static async Task LoadAppliedJobs()
        {
            try
            {
                JobSavedRestClient  js          = new JobSavedRestClient();
                List <JobDataModel> newJobsList = await js.GetSavedJobs(URLConfig.AppliedJobsurl);

                newJobsList = await BindJobsData(newJobsList);

                if (newJobsList != null && newJobsList.Count > 0)
                {
                    foreach (var item in newJobsList)
                    {
                        if (JobListHelper.AppliedJobsModel.Any(d => d.Id == item.Id) == false)
                        {
                            JobListHelper.AppliedJobsModel.Add(item);
                        }
                    }

                    JobListHelper.AppliedJobsModel = JobListHelper.AppliedJobsModel.OrderByDescending(d => d.CreatedDate).ToList();
                }
            }
            catch (Exception ex)
            {
                var logged = new LoggedException.LoggedException("Error while trying to bind applied jobs models", ex);
                await logged.LoggAPI();
            }
        }
Exemple #2
0
        public static async Task LoadSavedJobs()
        {
            try
            {
                JobSavedRestClient js = new JobSavedRestClient();


                List <JobDataModel> newJobsList = await js.GetSavedJobs(URLConfig.SavedJobsUrl);

                newJobsList = await BindJobsData(newJobsList);

                if (newJobsList != null && newJobsList.Count > 0)
                {
                    JobListHelper.SavedJobsModel = newJobsList.OrderByDescending(d => d.SavedDate).ToList();
                }
            }
            catch (Exception ex)
            {
                var logged = new LoggedException.LoggedException("Error while trying to bind saved jobs models", ex);
                await logged.LoggAPI();
            }
        }
Exemple #3
0
        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();
            }
        }