Ejemplo n.º 1
0
        async Task SetMyJobPostsList()
        {
            try
            {
                var         user        = App.Database.GetLoggedUser();
                JobServices jobServices = new JobServices();
                var         js          = await jobServices.GetMyJobs(user.Id);

                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);
                }
                MyJobsList = new ObservableCollection <JobsHome>(js.Data);
                //lvMyJobPost.ItemsSource = jobsViewModel.JobFullList;
                //lblJobsCount.Text = js.Count() + " Jobs found in " + selectedHelpersInCluster.LocationName;
                //aiJobPost.IsRunning = false;
            }
            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;
            }
        }
Ejemplo n.º 3
0
        //protected override async void OnAppearing()
        //{
        //    base.OnAppearing();

        //    await GetRuntimeLocationPermission(5000);
        //}


        async void ShowHelperHalfList(string selectedCluster)
        {
            try
            {
                rlHalfJobView.IsVisible = true;

                var selectedHelpersInCluster = jobsViewModel.jobPostList.Where(h => h.LocationName == (selectedCluster)).FirstOrDefault();
                mapJob.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(selectedHelpersInCluster.Latitude - 0.0055, selectedHelpersInCluster.Longitude), Distance.FromKilometers(1)));

                IEnumerable <JobsHome> js          = new List <JobsHome>();
                JobServices            jobServices = new JobServices();

                RegisterUserModel loggedUser = App.Database.GetLoggedUser();
                if (loggedUser == null)
                {
                    js = await jobServices.GetJobsInLocation(selectedHelpersInCluster.Latitude, selectedHelpersInCluster.Longitude, 0);
                }
                else
                {
                    js = await jobServices.GetJobsInLocation(selectedHelpersInCluster.Latitude, selectedHelpersInCluster.Longitude, loggedUser.Id);
                }

                for (int i = 0; i < js.Count(); i++)
                {
                    JobsHome j = js.ElementAt(i);
                    if (j != null)
                    {
                        if (j.BookMark)
                        {
                            j.BookmarkImage = "save_filled.png";
                        }
                        else
                        {
                            j.BookmarkImage = "save.png";
                        }

                        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.Select(x => x.JobId == j.JobId ? j : x);
                }

                jobsViewModel.JobPostHalfList = new ObservableCollection <JobsHome>(js);
                lvHalfJobs.ItemsSource        = jobsViewModel.JobPostHalfList;
                lblJobsCount.Text             = js.Count() + " Jobs found in " + selectedHelpersInCluster.LocationName;
            }
            catch (Exception e)
            {
                Console.Write(e.StackTrace);
            }
        }