public static async void SendApplicationNoticeEmail(string recipient, Journeys j) { string message = string.Format("Hey your journey on the {2} has new applicants. \n\nDetails: \nFrom: {0}\nTo: {1}\nOn: {2}\nAt: {3}\n\nLog In to the app to review the applicants!", j.From, j.To, j.DepartureDate, j.DepartureDateTime); var client = new SendGridClient(SendGridAPIKey); var msg = new SendGridMessage() { From = new EmailAddress("*****@*****.**", "CAIRDE - New Applicants"), Subject = "CarSharing Journey Application", PlainTextContent = message, HtmlContent = "<strong>" + message.Replace("\n", "<br />") + "</strong>" }; msg.AddTo(new EmailAddress(recipient, "User")); var response = await client.SendEmailAsync(msg); }
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); }
public static async void UpdateJourney(Journeys j) { CurrentPlatform.Init(); MobileService.GetTable <Journeys>().UpdateAsync(j); }
public static async void InsertJourney(Journeys j) { CurrentPlatform.Init(); MobileService.GetTable <Journeys>().InsertAsync(j); }