Example #1
0
        public static async Task <UserProfiles> GetUsersProfile(string userID)
        {
            CurrentPlatform.Init();
            List <UserProfiles> ls = await MobileService.GetTable <UserProfiles>().ToListAsync();

            UserProfiles u = ls.FirstOrDefault(x => x.UsersID == userID);

            return(u);
        }
Example #2
0
        public static async void InsertUserProfile(string userID, string firstName, string lastName, string email, string phoneNo, string gender, string county)
        {
            CurrentPlatform.Init();
            UserProfiles up = new UserProfiles
            {
                UsersID   = userID,
                Firstname = firstName,
                Lastname  = lastName,
                Email     = email,
                PhoneNo   = phoneNo,
                Gender    = gender,
                County    = county
            };

            MobileService.GetTable <UserProfiles>().InsertAsync(up);
        }
Example #3
0
        public static async Task <bool> IsUserProfileCreated(string userID)
        {
            CurrentPlatform.Init();
            List <UserProfiles> ls = await MobileService.GetTable <UserProfiles>().ToListAsync();

            UserProfiles u = ls.FirstOrDefault(x => x.UsersID == userID);

            if (u != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
 public static async void InsertUserProfile(UserProfiles up)
 {
     CurrentPlatform.Init();
     MobileService.GetTable <UserProfiles>().InsertAsync(up);
 }
Example #5
0
        public static async Task <bool> SetupDemoData() //This method will populate the database with test users, and test journeys, old and new etc
        {
            Random              rnd          = new Random();
            List <Users>        demoUsers    = new List <Users>();
            List <UserProfiles> demoProfiles = new List <UserProfiles>();

            #region setupUsers
            string   password  = PasswordStorage.CreateHash("Carshar1ng");
            string[] userNames = new string[30] {
                "Dylan", "Paul", "Evelin", "Zoe", "Tommy",
                "Carl", "Derek", "Carol", "Dean", "Erica",
                "Roisin", "Laura", "Ken", "Ron", "Ross",
                "Barbie", "Sean", "Dan", "Rory", "Rachael",
                "Phoebe", "Dolores", "Leo", "Lucifer", "Carlos",
                "Renee", "Zed", "Damien", "Nicole", "David"
            };
            foreach (string s in userNames)
            {
                Users user = new Users()
                {
                    Username = s, Password = password
                };
                InsertNewUser(user);
            }
            foreach (string s in userNames)
            {
                Users user = await GetUser(s);

                demoUsers.Add(user);
            }
            #endregion
            #region setup Profiles
            string   lastName = "TestUser";
            string   email    = "*****@*****.**";
            string   phone    = "0857584241";
            string[] gender   = new string[3] {
                "Male", "Female", "Prefer not to Disclose"
            };
            string[] county = new string[6] {
                "Carlow", "Dublin", "Cork", "Galway", "Waterford", "Limerick"
            };
            foreach (Users u in demoUsers)
            {
                UserProfiles userProfile = new UserProfiles()
                {
                    UsersID   = u.ID,
                    Firstname = u.Username,
                    Lastname  = lastName,
                    Email     = email,
                    PhoneNo   = phone,
                    Gender    = gender[rnd.Next(0, gender.Length)],
                    County    = county[rnd.Next(0, county.Length)]
                };
                InsertUserProfile(userProfile);
            }
            foreach (Users u in demoUsers)
            {
                UserProfiles up = await GetUsersProfile(u.ID);

                demoProfiles.Add(up);
            }
            #endregion
            #region Create Journeys
            int      i;
            LatLng[] locations = new LatLng[6]
            {
                new LatLng(52.836438, -6.932914),
                new LatLng(53.347548, -6.259539),
                new LatLng(51.891959, -8.483876),
                new LatLng(53.269885, -9.056660),
                new LatLng(52.261530, -7.111773),
                new LatLng(52.667267, -8.631729)
            };
            DateTime[] depDates = new DateTime[11]
            {
                DateTime.Now.AddDays(-1),
                DateTime.Now,
                DateTime.Now.AddDays(1),
                DateTime.Now.AddDays(2),
                DateTime.Now.AddDays(3),
                DateTime.Now.AddDays(4),
                DateTime.Now.AddDays(5),
                DateTime.Now.AddDays(6),
                DateTime.Now.AddDays(7),
                DateTime.Now.AddDays(8),
                DateTime.Now.AddDays(9)
            };
            DateTime   baseTime = new DateTime(2018, 4, 4, 7, 0, 0);
            DateTime[] depTimes = new DateTime[10]
            {
                baseTime,
                baseTime.AddMinutes(30),
                baseTime.AddMinutes(60),
                baseTime.AddMinutes(90),
                baseTime.AddMinutes(120),
                baseTime.AddMinutes(150),
                baseTime.AddMinutes(180),
                baseTime.AddMinutes(600),
                baseTime.AddMinutes(660),
                baseTime.AddMinutes(720)
            };
            for (i = 0; i < 1000; i++)
            {
                LatLng loc  = locations[rnd.Next(0, 6)];
                LatLng des  = locations[rnd.Next(0, 6)];
                string user = demoUsers[rnd.Next(0, demoUsers.Count)].ID;
                while (des.Latitude == loc.Latitude)
                {
                    des = locations[rnd.Next(0, 6)];
                }
                Journeys randJourney = new Journeys()
                {
                    CreatedBy         = user,
                    From              = LocationHelper.ReverseGeoLoc(loc),
                    To                = LocationHelper.ReverseGeoLoc(des),
                    FromLat           = loc.Latitude,
                    ToLat             = des.Latitude,
                    FromLon           = loc.Longitude,
                    ToLon             = des.Longitude,
                    DriverID          = user,
                    NoOfPassengers    = rnd.Next(1, 5),
                    DepartureDate     = depDates[rnd.Next(0, depDates.Count())].ToShortDateString(),
                    DepartureDateTime = depTimes[rnd.Next(0, depTimes.Count())].ToShortTimeString(),
                    Filled            = false,
                    Completed         = false,
                    Applicants        = "",
                    Passengers        = ""
                };
                InsertJourney(randJourney);
            }
            #endregion

            return(true);
        }