public void TestNullDictionary()
        {
            Dictionary <string, int>    dict = null;
            List <Tuple <string, int> > list = null;

            Backend.HelperServices helper = new HelperServices();
            helper.AddPopulationsToDictionary(dict, list);
        }
Beispiel #2
0
 public UsersController(ChatyDb context, IHubContext <ChatHub> chatHub,
                        Microsoft.Extensions.Configuration.IConfiguration configuration, IHostingEnvironment hostingEnvironment)
 {
     _context            = context;
     _chatHub            = chatHub;
     _hostingEnvironment = hostingEnvironment;
     helperServices      = new HelperServices(configuration);
 }
Beispiel #3
0
        public void GetImageFilePaths_PathInvalid()
        {
            _fileSystem.Setup(f => f.Directory.Exists(It.IsAny <string>())).Returns(false);
            var helper = new HelperServices(_fileSystem.Object);
            var result = helper.GetImageFilePaths(@"c:\temp");

            Assert.NotNull(result);
            Assert.Empty(result);
        }
Beispiel #4
0
        public void VerifyDirectory_DoesExist()
        {
            _fileSystem.Setup(f => f.Directory.Exists(It.IsAny <string>())).Returns(true);
            var helper   = new HelperServices(_fileSystem.Object);
            var filePath = @"c:\temp";
            var result   = helper.VerifyDirectory(filePath);

            Assert.NotEmpty(result);
            Assert.Equal(filePath, result);
        }
        async void GotoNextService(int i)
        {
            if (i >= helperServices.Service.Count)
            {
                helperServices = (await(new HelpersServices()).SaveHelperServices(helperServices));

                if (helperServices.HelperId != 0)
                {
                    RegisterUserModel user = App.Database.GetUsers(helperServices.UserId);
                    user.IsServiced = true;
                    App.Database.SaveUser(user);

                    await DisplayAlert("Information", "Services saved successfully", "Ok");

                    GoToBuildTrust();
                }
                else
                {
                    await DisplayAlert("Error", "Somethin wrong! Please try again.", "Ok");
                }


                return; // Call HelperServices and go to Build Trust
            }

            var g = gridHelperEditServices.Children.ElementAt(i + 1);

            g.BackgroundColor = Color.FromHex("#FF748C");

            svHelperEditServices.IsVisible  = false;
            svHelperRegHelperHome.IsVisible = true;

            // Reset data
            HelperServices service = helperServices.Service.ElementAt(i);

            btnHelperRegSelectedService.Text = service.ServiceName;

            SetScopes(service.ServiceId);
            SetPriceType();
            helperServices.Service[i].Scopes = new List <HelperScopes>();

            entryHelperRegLocation.Text = "";

            //btnHelperRegHourly.isSelected = false;
            gridPriceHour.IsVisible = false;

            //btnHelperRegMonthly.isSelected = false;
            gridPriceMonth.IsVisible = false;

            //btnHelperRegDaily.isSelected = false;
            gridPriceDay.IsVisible = false;

            //btnHelperRegTbd.isSelected = false;
        }
        public void TestNullAPIList()
        {
            //database entry
            Dictionary <string, int> dict = new Dictionary <string, int>();

            //API entry
            List <Tuple <string, int> > list = null;

            Backend.HelperServices helper = new HelperServices();
            dict = helper.AddPopulationsToDictionary(dict, list);
        }
Beispiel #7
0
        public async void RefreshMap()
        {
            // Clear Features
            Map.MapElements.Clear();
            Map.Pins.Clear();

            DrawFeatures();

            //SetShowingUser
            PermissionStatus status = await HelperServices.CheckAndRequestPermissionAsync(new Permissions.LocationWhenInUse());

            Map.IsShowingUser = status == PermissionStatus.Granted;
        }
Beispiel #8
0
        // Only center map on user if location permissions are granted otherwise center on Brisbane
        private async void CenterMapOnUser()
        {
            try
            {
                Position location = await HelperServices.GetGeoLocation();

                Map.MoveToRegion(MapSpan.FromCenterAndRadius(new XFMPosition(location.Latitude, location.Longitude), Distance.FromMiles(1.0)));
            }
            catch
            {
                Map.MoveToRegion(MapSpan.FromCenterAndRadius(new XFMPosition(-27.47, 153.021), Distance.FromMiles(1.0)));
            }
        }
Beispiel #9
0
        public void GetImageFilePaths_PathValid(string[] fileArray)
        {
            _fileSystem.Setup(f => f.Directory.Exists(It.IsAny <string>())).Returns(true);
            _fileSystem.Setup(f => f.Directory.GetFiles(It.IsAny <string>())).Returns((string _) =>
                                                                                      fileArray);

            var helper = new HelperServices(_fileSystem.Object);
            var result = helper.GetImageFilePaths(@"c:\temp");

            Assert.NotNull(result);
            Assert.Equal(fileArray.Length, result.Length);
            foreach (var file in fileArray)
            {
                Assert.Contains(file, result);
                Assert.Contains(file, result);
            }
        }
        public void TestAddPopulationsToDictionary()
        {
            Dictionary <string, int> dict = new Dictionary <string, int>();

            List <Tuple <string, int> > list = new List <Tuple <string, int> >
            {
                Tuple.Create("India", 1182105000)
            };

            Backend.HelperServices helper = new HelperServices();
            helper.AddPopulationsToDictionary(dict, list);

            foreach (KeyValuePair <string, int> entry in dict)
            {
                Assert.AreEqual(entry.Key, "India");
                Assert.AreEqual(entry.Value, 1182105000);
            }
        }
        public void TestPrintDictionary()
        {
            //Arrange with all the variables needed in the test
            Dictionary <string, int> dict = new Dictionary <string, int>();

            dict.Add("India", 1182105000);
            dict.Add("United Kingdom", 62026962);
            dict.Add("Chile", 17094270);
            dict.Add("Mali", 15370000);
            dict.Add("Greece", 11305118);
            dict.Add("Armenia", 3249482);
            dict.Add("Slovenia", 2046976);

            //Act
            Backend.HelperServices helper = new HelperServices();

            helper.PrintDictionary(dict);
        }
        public void TestSameCountryFromAPIAndDatabase()
        {
            //database entry
            Dictionary <string, int> dict = new Dictionary <string, int>();

            dict.Add("India", 1210854977);

            //API entry
            List <Tuple <string, int> > list = new List <Tuple <string, int> >
            {
                Tuple.Create("India", 1182105000)
            };

            Backend.HelperServices helper = new HelperServices();
            dict = helper.AddPopulationsToDictionary(dict, list);

            foreach (KeyValuePair <string, int> entry in dict)
            {
                Assert.AreEqual(entry.Key, "India");
                Assert.AreEqual(entry.Value, 1210854977);
            }
        }
        public void TestSameCountryFromAPIAndDatabaseDifferentRepresentation()
        {
            //database entry
            Dictionary <string, int> dict = new Dictionary <string, int>();

            dict.Add("U.S.A.", 311976362);

            //API entry
            List <Tuple <string, int> > list = new List <Tuple <string, int> >
            {
                Tuple.Create("United States of America", 1182105000)
            };

            Backend.HelperServices helper = new HelperServices();
            dict = helper.AddPopulationsToDictionary(dict, list);

            foreach (KeyValuePair <string, int> entry in dict)
            {
                Assert.AreEqual(entry.Key, "U.S.A.");
                Assert.AreEqual(entry.Value, 311976362);
            }
        }
        void OnCallNextService(object sender, EventArgs args)
        {
            try
            {
                // List<ServiceModel> selectedServices = App.Database.GetServicesAsync();
                if (entryHelperRegLocation.Text.Equals(""))
                {
                    DisplayAlert("Warning", "Please select location.", "Ok");
                    return;
                }

                //Save services data
                HelperServices service = new HelperServices();
                if (rgHelperHomeLocation.Checked)
                {
                    helperServices.Service[currentService].LocationType = "S";
                }
                else
                {
                    helperServices.Service[currentService].LocationType = "M";
                }

                if (((ServiceButton)gridPriceType.Children.ElementAt(0)).isSelected)
                {
                    helperServices.Service[currentService].Hour         = true;
                    helperServices.Service[currentService].MinPriceHour = float.Parse(btnHelperRegPriceHrMin.Text.Substring(2));
                    helperServices.Service[currentService].MaxPriceHour = float.Parse(btnHelperRegPriceHrMax.Text.Substring(2));
                }

                if (((ServiceButton)gridPriceType.Children.ElementAt(1)).isSelected)
                {
                    helperServices.Service[currentService].Day         = true;
                    helperServices.Service[currentService].MinDayPrice = float.Parse(btnHelperRegPriceDayMin.Text.Substring(2));
                    helperServices.Service[currentService].MaxDayPrice = float.Parse(btnHelperRegPriceDayMax.Text.Substring(2));
                }

                if (((ServiceButton)gridPriceType.Children.ElementAt(2)).isSelected)
                {
                    helperServices.Service[currentService].Month         = true;
                    helperServices.Service[currentService].MinMonthPrice = float.Parse(btnHelperRegPriceMonthMin.Text.Substring(2));
                    helperServices.Service[currentService].MaxMonthPrice = float.Parse(btnHelperRegPriceMonthMax.Text.Substring(2));
                }

                //helperServices.Service[currentService].Scopes = new List<HelperScopes>();
                //HelperScopes scope = new HelperScopes();
                //foreach (ScopeModel scope in scopes)
                //{
                //    helperServices.Service[currentService].Scopes.Add(scope.ScopeId);
                //    services.ElementAt(currentService).Scopes = (scopes);
                //}

                //Save Service into database
                //App.Database.SaveServiceAsync(service);

                GotoNextService(++currentService);
            }
            catch (Exception e)
            {
                Console.Write(e.StackTrace);
            }
        }
        public HelperCompleteRegister(RegisterUserModel user)
        {
            InitializeComponent();

            currentService = 0;
            instance       = this;
            NavigationPage.SetHasNavigationBar(this, false);
            currentUser = user;

            btnHelperRegSelectedService.isSelected = true;
            //btnHelperRegTbd.isSelected = false;

            entryHelperRegUsername1.Text = user.UserName;
            entryHelperRegPhone1.Text    = user.MobileNumber;
            entryHelperRegEmail1.Text    = user.Email;

            IEnumerable <string> genders = new List <string>()
            {
                "Male", "Female", "Rather no to say"
            };

            SetRadioList(genders, rgHelperGender);

            //IEnumerable<String> locationTypes = new List<string>() { "Helper's Home", "Mobile Helper"};
            //SetRadioList(locationTypes, rgHelperLocationType);

            IEnumerable <string> statusList = new List <string>()
            {
                "Available", "Not available"
            };

            SetRadioList(statusList, rgHelperStatus);

            SetServices();

            //if (user.IsServiced)
            //    GoToBuildTrust();
            //else
            //if (user.IsCompleted)
            //    GoToEditServices();
            //else
            //if (user.IsRegistered)
            //{
            //    GoToBasicInfo();
            //}

            MessagingCenter.Subscribe <HelperRegister2, string>(this, "Current Address", (sender, currLoc) =>
            {
                string[] locations          = currLoc.Split(new char[] { ';' });
                entryHelperRegLocation.Text = locations[0];
                helperServices.Service[currentService].LocationName = locations[0];
                helperServices.Service[currentService].Latitude     = locations[1];
                helperServices.Service[currentService].Longitude    = locations[2];
            });

            MessagingCenter.Subscribe <HelperRegister3, string>(this, "Selected Address", (sender, selectedAddress) =>
            {
                entryHelperRegLocation.Text = selectedAddress;
            });

            MessagingCenter.Subscribe <ServiceButton, bool>(this, "Select Or Unselect Service", (sender, isSelected) =>
            {
                try
                {
                    string serviceName = ((ServiceButton)sender).serviceName;

                    if (string.Equals(serviceName, "Hourly"))
                    {
                        if (((ServiceButton)sender).isSelected)
                        {
                            gridPriceHour.IsVisible = true;
                        }
                        else
                        {
                            gridPriceHour.IsVisible = false;
                        }
                    }
                    else if (string.Equals(serviceName, "Daily"))
                    {
                        if (((ServiceButton)sender).isSelected)
                        {
                            gridPriceDay.IsVisible = true;
                        }
                        else
                        {
                            gridPriceDay.IsVisible = false;
                        }
                    }
                    else if (string.Equals(serviceName, "Monthly"))
                    {
                        if (((ServiceButton)sender).isSelected)
                        {
                            gridPriceMonth.IsVisible = true;
                        }
                        else
                        {
                            gridPriceMonth.IsVisible = false;
                        }
                    }
                    else
                    {
                        List <ServiceModel> services = App.Database.GetServices();
                        ServiceModel service         = services.Where(a => a.ServiceName == serviceName).FirstOrDefault();
                        //var selectedService = helperServices.Service.Where(a => a.ServiceId == service.Id).FirstOrDefault();
                        int serviceIndex = services.IndexOf(service);
                        var gService     = gridServices.Children.Where(c => Grid.GetRow(c) == (serviceIndex) / 3 && Grid.GetColumn(c) == (serviceIndex) % 3);
                        gService.ElementAt(1).IsVisible = !gService.ElementAt(1).IsVisible;

                        if (isSelected)
                        {
                            AddGrid(gridHelperEditServices);

                            HelperServices helperService = new HelperServices();
                            helperService.ServiceId      = service.Id;
                            helperService.ServiceName    = service.ServiceName;
                            helperServices.Service.Add(helperService);

                            //selectedService.isSelected = true;
                            //App.Database.SaveServiceAsync(selectedService);
                        }
                        else
                        {
                            int count = gridHelperEditServices.ColumnDefinitions.Count;

                            for (int i = count - 1; i >= 0; i--)
                            {
                                gridHelperEditServices.ColumnDefinitions.RemoveAt(i);
                                gridHelperEditServices.Children.RemoveAt(i);
                            }

                            for (int i = 0; i < count - 1; i++)
                            {
                                AddGrid(gridHelperEditServices);
                            }

                            HelperServices helperService = helperServices.Service.Where(a => a.ServiceId == service.Id).FirstOrDefault();
                            helperServices.Service.Remove(helperService);

                            //selectedService.isSelected = false;
                            //App.Database.SaveServiceAsync(selectedService);
                        }

                        var g             = gridHelperEditServices.Children.Where(c => Grid.GetRow(c) == 0 && Grid.GetColumn(c) == 0).First();
                        g.BackgroundColor = Color.FromHex("#FF748C");
                    }
                }
                catch (Exception e)
                {
                    Console.Write(e.StackTrace);
                }
            });

            MessagingCenter.Subscribe <ScopeButton, bool>(this, "Select Or Unselect Service", (sender, isSelected) =>
            {
                try
                {
                    string scopeName         = ((ScopeButton)sender).scopeName;
                    List <ScopeModel> scopes = App.Database.GetScopes();
                    ScopeModel scope         = scopes.Where(a => a.ScopeName == scopeName).FirstOrDefault();

                    if (isSelected)
                    {
                        HelperScopes helperScope = new HelperScopes()
                        {
                            ScopeId = scope.Id
                        };
                        helperServices.Service[currentService].Scopes.Add(helperScope);
                    }
                    else
                    {
                        HelperScopes helperScope = helperServices.Service[currentService].Scopes.Where(x => x.ScopeId == scope.Id).FirstOrDefault();
                        helperServices.Service[currentService].Scopes.Remove(helperScope);
                    }

                    //App.Database.SaveScopeAsync(selectedScope);
                }
                catch (Exception e)
                {
                    Console.Write(e.StackTrace);
                }
            });
        }
 public MessagesController(ChatyDb context, IHubContext <ChatHub> chatHub, Microsoft.Extensions.Configuration.IConfiguration configuration)
 {
     _context       = context;
     _chatHub       = chatHub;
     helperServices = new HelperServices(configuration);
 }