public ViewerType GetViewerType(ApplicationUser user, TripDetails tripDetails) { if (user == null) { return(ViewerType.Guest); } if (user.Id == tripDetails.DriverId) { return(ViewerType.Driver); } if (tripDetails.Passangers != null) { foreach (var pass in tripDetails.Passangers) { if (pass.User == user) { return(ViewerType.Passanger); } } } return(ViewerType.Guest); }
public static async Task <string> DownloadStringAsync(TripDetails trips, string type) { string strUri = _GoogleDirectionAPIAddress + "?origin=" + trips.originLatLng + "&destination=" + trips.destinationLatLng + "&waypoints=optimize:true&key=" + _GoogleAPIKey; WebClient webclient = new WebClient(); string strResultData; try { strResultData = await webclient.DownloadStringTaskAsync(new Uri(strUri)); Console.WriteLine(strResultData); } catch { strResultData = "Exception"; } finally { webclient.Dispose(); webclient = null; } return(strResultData); }
/// <summary> /// Function that finds both distance and duration between two given points /// temporary logic for distance and duration in minutes /// assumes distance and duration are always less than int32.max /// </summary> /// <param name="fSrcX"></param> /// <param name="fSrcY"></param> /// <param name="fDestX"></param> /// <param name="fDestY"></param> /// <returns></returns> static TripDetails FindTripDetails(int fSrcX, int fSrcY, int fDestX, int fDestY) { int distance = 0; int deltaX = fDestX - fSrcX; int deltaY = fDestY - fSrcY; distance = Convert.ToInt32(Math.Sqrt(deltaX * deltaX + deltaY * deltaY)); //temporary logic - 5 points equals 1Km, and 1Km takes 2 min. int duration = (distance / 5) * 2; TripDetails tripDetails = new TripDetails { srcX = fSrcX, srcY = fSrcY, destX = fDestX, destY = fDestY, distance = distance, durationMinutes = duration }; return(tripDetails); }
public override void ParseResults(XDocument xmlDoc, Exception error) { TripDetails tripDetail = new TripDetails(); if (xmlDoc == null || error != null) { callback(tripDetail, error); } else { try { tripDetail = (from trip in xmlDoc.Descendants("entry") select ParseTripDetails(trip)).First(); } catch (WebserviceResponseException ex) { error = ex; } catch (Exception ex) { error = new WebserviceParsingException(requestUrl, xmlDoc.ToString(), ex); } } Debug.Assert(error == null); callback(tripDetail, error); }
public async Task <ActionResult <TripDetails> > PostTripDetails(TripDetails tripDetails) { _context.TripDetails.Add(tripDetails); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTripDetails", new { id = tripDetails.Trip_id }, tripDetails)); }
public static async Task <string> DownloadStringAsync(TripDetails trips) { string waypoints = ""; foreach (TripPassenger tp in trips.TripPassengers) { waypoints += "|" + tp.originLatLng; Console.WriteLine("=== waypoints " + waypoints); } string strUri = _GoogleDirectionAPIAddress + "?origin=" + trips.originLatLng + "&destination=" + trips.destinationLatLng + "&waypoints=optimize:true" + waypoints + "&key=" + _GoogleAPIKey; Console.WriteLine("=== uri " + strUri); WebClient webclient = new WebClient(); string strResultData; try { strResultData = await webclient.DownloadStringTaskAsync(new Uri(strUri)); Console.WriteLine(strResultData); } catch { strResultData = "Exception"; } finally { webclient.Dispose(); webclient = null; } return(strResultData); }
public void PrimeAddPerson() { PersonRepository repo = GetComponent <PersonRepository>(); TripDetails details = GetComponent <TripDetails>(); dropdownOptions = new List <string>(); AddPersonToTrip.options.Clear(); foreach (KeyValuePair <int, Person> person in repo.People) { bool personNotYetInTrip = true; foreach (KeyValuePair <int, Person> TripPerson in details.Trip.PeopleOnTrip) { if (personNotYetInTrip) { personNotYetInTrip = TripPerson.Value.Id != person.Value.Id; } } if (personNotYetInTrip) { dropdownOptions.Add(person.Value.PersonName); } } AddPersonToTrip.AddOptions(dropdownOptions); if (dropdownOptions.Count != 0) { selectedPerson = dropdownOptions[0]; } }
public void ValidateExpenseName() { InputField ExpenseName = GameObject.Find("ExpenseNameAnswer").GetComponent <InputField>(); TripDetails details = GetComponent <TripDetails>(); submitButton.interactable = !string.IsNullOrEmpty(ExpenseName.text) && !(details.Trip.PeopleOnTrip.Count < 2); Text invalidPeople = GameObject.Find("InvalidWhoPaidName").GetComponent <UnityEngine.UI.Text>(); if (string.IsNullOrEmpty(ExpenseName.text)) { invalidExpenseName.text = "Name cannot be empty"; } else { invalidExpenseName.text = ""; } if (details.Trip.PeopleOnTrip.Count < 2) { invalidPeople.text = "Expense need at least two people, please add more people to the trip"; } else { invalidPeople.text = ""; } }
protected override void OnCreate(Bundle savedInstanceState) { SetTheme(Android.Resource.Style.ThemeDeviceDefault); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.SearchDriverListView); ActionBar ab = ActionBar; ab.SetDisplayHomeAsUpEnabled(true); Android.Net.ConnectivityManager cm = (Android.Net.ConnectivityManager) this.GetSystemService(Context.ConnectivityService); if (cm.ActiveNetworkInfo == null) { Toast.MakeText(this, "Network error. Try again later.", ToastLength.Long).Show(); } else { passTrip = JsonConvert.DeserializeObject <TripDetails>(Intent.GetStringExtra("Trip")); listView = FindViewById <ListView>(Resource.Id.driver_listview); progress = new Android.App.ProgressDialog(this); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetMessage("Looking for drivers....."); progress.SetCancelable(false); LoadDriverDetails(passTrip.TripPassengerID); } }
protected override void OnCreate(Bundle savedInstanceState) { SetTheme(Android.Resource.Style.ThemeDeviceDefault); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.DriverProfileDetail); ActionBar ab = ActionBar; ab.SetDisplayHomeAsUpEnabled(true); progress = new Android.App.ProgressDialog(this); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetMessage("Loading driver profile..."); progress.SetCancelable(false); tripDetail = JsonConvert.DeserializeObject <TripDetails>(Intent.GetStringExtra("Trip")); // Member variable views tvUsername = (TextView)FindViewById(Resource.Id.username); tvPhone = (TextView)FindViewById(Resource.Id.phone); tvGender = (TextView)FindViewById(Resource.Id.gender); // Vehicle variable views tvMake = (TextView)FindViewById(Resource.Id.carmake); tvModel = (TextView)FindViewById(Resource.Id.carmodel); tvColor = (TextView)FindViewById(Resource.Id.color); tvCarplate = (TextView)FindViewById(Resource.Id.carplate); LoadDriverProfile(tripDetail.TripDriver.Member.MemberID); }
public List <TripDetails> GetTripDetails(int tripId) { var getTripUser = from trips in _db.TripDetails join frndtrip in _db.FriendTripMappings on trips.Id equals frndtrip.TripId join exp in _db.TripExpenses on frndtrip.FriendId equals exp.FriendId join usr in _db.UsersInfoes on frndtrip.FriendId equals usr.Id where trips.Id == tripId && exp.TripId == tripId select new { trips.Id, trips.TripTitle, trips.StartDate, trips.EndDate, usr.FirstName, usr.LastName, usr.EmailId, exp.Amount, usr.Image }; var tripDetail = new List <TripDetails>(); var emailIdKey = getTripUser.GroupBy(a => a.EmailId); foreach (var tdList in emailIdKey) { var td = new TripDetails(); td.EmailId = tdList.Key; td.Name = tdList.FirstOrDefault(a => a.EmailId == tdList.Key).FirstName + " " + tdList.FirstOrDefault(a => a.EmailId == tdList.Key).LastName; td.TripTitle = tdList.FirstOrDefault(a => a.EmailId == tdList.Key).TripTitle; td.fromDate = tdList.FirstOrDefault(a => a.EmailId == tdList.Key).StartDate; td.toDate = tdList.FirstOrDefault(a => a.EmailId == tdList.Key).EndDate; double amount = 0; foreach (var amt in tdList) { amount = amount + (double)(amt.Amount); } td.Amount = amount; tripDetail.Add(td); } return(tripDetail); }
public IActionResult ConfirmationPositive(string answer, TripCreatorViewModel model) { if (!String.IsNullOrWhiteSpace(answer)) { switch (answer) { case "Accept": TripDetails tripDetails = model.GetTripDetailsModel(); tripDetails.DriverId = accountManager.GetUserId(HttpContext.User); if (model.MapData != null) { var id = fileManager.SaveFile(model.MapData, "wwwroot/images/maps/"); tripDetails.MapId = id; } tripDetailsRepository.Add(tripDetails); htmlNotification.SetNotification(HttpContext.Session, "res-suc", "Trip was succesfully created!"); return(RedirectToAction("Index", "Home")); case "Decline": return(View("Index")); default: return(RedirectToAction("Index", "Home")); } } return(RedirectToAction("Index", "Home")); }
public ActionResult Calculate(IEnumerable <Student> students) { TripDetails trip = new TripDetails(); foreach (Student s in students) { if (s.Name == " ") { ViewBag.warningMessage = "Please fill out all fields"; return(View(students)); } trip.total += s.paidAmount; trip.students.Add(s); } trip = trip.calculateExpenses(); //Build string string output = ""; foreach (var i in trip.oweTable) { Student from = i.Item1; Student to = i.Item2; decimal amount = i.Item3; output += string.Format("{0} owes {1} ${2:f2}. <br>", from.Name, to.Name, amount); } ViewBag.output = output; return(View(students)); }
private void DrawMarkers(TripDetails tripDetail) { // Draw Markers string[] origin = tripDetail.originLatLng.Split(','); string[] destination = tripDetail.destinationLatLng.Split(','); LatLng o = new LatLng(double.Parse(origin[0]), double.Parse(origin[1])); LatLng d = new LatLng(double.Parse(destination[0]), double.Parse(destination[1])); mMap.AddMarker(new MarkerOptions().SetPosition(o).SetTitle("Origin")); mMap.AddMarker(new MarkerOptions().SetPosition(d).SetTitle("Destination")); if (tripDetail.TripPassengers != null) { foreach (TripPassenger tp in tripDetail.TripPassengers) { string[] w = tp.originLatLng.Split(','); LatLng waypoint = new LatLng(double.Parse(w[0]), double.Parse(w[1])); mMap.AddMarker(new MarkerOptions().SetPosition(waypoint).SetTitle("waypoint")); } } // Zoom map to the set padding LatLngBounds.Builder builder = new LatLngBounds.Builder(); builder.Include(o); builder.Include(d); LatLngBounds bounds = builder.Build(); int padding = 100; CameraUpdate cu = CameraUpdateFactory.NewLatLngBounds(bounds, padding); mMap.AnimateCamera(cu); }
public async Task <IActionResult> PutTripDetails(int id, TripDetails tripDetails) { if (id != tripDetails.Trip_id) { return(BadRequest()); } _context.Entry(tripDetails).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TripDetailsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void PrimeAddCurrencyToExpense(Dropdown dropdown) { CurrencyRepository repo = GetComponent <CurrencyRepository>(); TripDetails details = GetComponent <TripDetails>(); ClearOptions(dropdown); foreach (Currency currency in repo.Currencies) { bool isCurrencyNotYetInTrip = true; foreach (Currency currencyInTrip in details.Trip.Currencies) { if (isCurrencyNotYetInTrip) { isCurrencyNotYetInTrip = currencyInTrip.CurrencyCode != currency.CurrencyCode; } else { break; } } if (!isCurrencyNotYetInTrip) { dropdownOptions.Add(currency.CurrencyCode); } } dropdown.AddOptions(dropdownOptions); if (dropdownOptions.Count != 0) { selectedCurrency = dropdownOptions[0]; } }
public void ThenTripDetailsPageOpens() { if (details == null) { details = new TripDetails(driver, scenarioContext); } details.IsTripDetailsPageOpened(); }
public TripDetailsViewModel CreateViewModel(TripDetails tripDetails) { var vm = wrape.CreateViewModel(tripDetails); vm.PassangersUsernames = (from tu in tripDetails.Passangers where tu.Accepted == true select tu.User.UserName).ToList(); return(vm); }
public void SubmitCurrency() { TripDetails trip = GetComponent <TripDetails>(); CurrencyRepository currencyRepo = GetComponent <CurrencyRepository>(); CurrencyDropDown dropDown = GetComponent <CurrencyDropDown>(); Currency currency = currencyRepo.GetCurrencyWithName(dropDown.selectedCurrency); trip.AddCurrency(currency); }
public RequestListViewAdapter(Context c, List <Request> requests, TripDetails passTrip) { this.requests = requests; this.passTrip = passTrip; context = c; client = new HttpClient(); client.BaseAddress = new Uri(context.GetString(Resource.String.RestAPIBaseAddress)); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); }
public ActionResult TripDetails() { ExpenseClient _exp = new ExpenseClient(); var friendsList = new TripDetails { FriendList = _exp.GetFriendsList(Convert.ToInt32(Session["UserId"].ToString())).ToList() }; return(View(friendsList)); }
private static TripDetails ParseTripDetails(XElement trip) { TripDetails tripDetails = new TripDetails(); tripDetails.tripId = SafeGetValue(trip.Element("tripId")); XElement statusElement; if (trip.Element("tripStatus") != null) { // ArrivalsForStop returns the status element as 'tripStatus' statusElement = trip.Element("tripStatus"); } else if (trip.Element("status") != null) { // The TripDetails query returns 'status' statusElement = trip.Element("status"); } else { // No status available, stop parsing here return(tripDetails); } // TODO: Log a warning for when the serviceDate is invalid. This might be a OBA bug, but I don't // have the debugging info to prove it string serviceDate = SafeGetValue(statusElement.Element("serviceDate")); if (string.IsNullOrEmpty(serviceDate) == false) { long serviceDateLong; bool success = long.TryParse(serviceDate, out serviceDateLong); if (success) { tripDetails.serviceDate = UnixTimeToDateTime(serviceDateLong); if (string.IsNullOrEmpty(SafeGetValue(statusElement.Element("predicted"))) == false && bool.Parse(SafeGetValue(statusElement.Element("predicted"))) == true) { tripDetails.scheduleDeviationInSec = int.Parse(SafeGetValue(statusElement.Element("scheduleDeviation"))); tripDetails.closestStopId = SafeGetValue(statusElement.Element("closestStop")); tripDetails.closestStopTimeOffset = int.Parse(SafeGetValue(statusElement.Element("closestStopTimeOffset"))); if (statusElement.Element("position") != null) { tripDetails.location = new GeoCoordinate( double.Parse(SafeGetValue(statusElement.Element("position").Element("lat")), NumberFormatInfo.InvariantInfo), double.Parse(SafeGetValue(statusElement.Element("position").Element("lon")), NumberFormatInfo.InvariantInfo) ); } } } } return(tripDetails); }
public TripDetailsViewModel CreateViewModel(TripDetails tripDetails) { var vm = wrape.CreateViewModel(tripDetails); vm.RequestsUsernames = new System.Collections.Generic.List <string>(); vm.RequestsUsernames = (from username in tripDetails.Passangers where username.Accepted == false select username.User.UserName).ToList(); return(vm); }
public void AddButtonOnClick() { GameObject tripPane = GameObject.Find("TripDetailsPane"); GameObject tripPanel = GameObject.Find("TripDetailsPanel"); tripPane.transform.SetAsLastSibling(); tripPanel.transform.SetAsLastSibling(); GameObject scripts = GameObject.Find("Scripts"); TripDetails details = scripts.GetComponent <TripDetails>(); details.Setup(Trip); }
public void totalCostTest() { TripDetails trip = new TripDetails(); Student one = new Student("Bob1", "Smith1", 132.54M); Student two = new Student("Bob", "Smith", 12.34M); Student three = new Student("Bob2", "Smith2", 32.32M); trip.students.Add(one); trip.students.Add(two); trip.students.Add(three); Assert.AreEqual(trip.total, (132.54 + 12.34 + 32.32)); }
/// <summary> /// Gets the trip details for the tracking data. /// </summary> public async Task GetTripDetailsAsync() { var obaDataAccess = ObaDataAccess.Create(); this.TripDetails = await obaDataAccess.GetTripDetailsAsync(this.trackingData.TripId); if (!string.IsNullOrEmpty(this.selectedStopId)) { this.SelectStop(this.selectedStopId); } this.IsLoadingTripDetails = false; }
public int SaveTripDetails(TripDetails tripDetails) { try { return(_expense.SaveTripDetails(tripDetails)); } catch (Exception e) { WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.PreconditionFailed; WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message; return(0); } }
public void SubmitPerson() { PeopleDropdown dropdown = GetComponent <PeopleDropdown>(); string name = dropdown.selectedPerson; PersonRepository repo = GetComponent <PersonRepository>(); TripDetails trip = GetComponent <TripDetails>(); trip.AddPerson(repo.GetPerson(name)); PersonList personList = GetComponent <PersonList>(); personList.Prime(); }
public TripDetailsViewModel CreateViewModel(TripDetails tripDetails) { var vm = wrape.CreateViewModel(tripDetails); if (tripDetails.MapId != null) { vm.MapPath = "/images/maps/" + tripDetails.MapId + ".json"; } else { vm.MapPath = null; } return(vm); }
public void studentListTest() { TripDetails trip = new TripDetails(); Student one = new Student("Bob1", "Smith1", 132.54M); Student two = new Student("Bob", "Smith", 12.34M); Student three = new Student("Bob2", "Smith2", 32.32M); trip.students.Add(one); trip.students.Add(two); trip.students.Add(three); Assert.AreEqual(trip.students, new List <Student> { one, two, three }); }