예제 #1
0
        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;
            }
        }
예제 #2
0
        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);
            }
        }