public float GetPrixVoyage(VOYAGE voyage, string De, string A) { var geocodingDe = GetCoordinates(De); var geocodingA = GetCoordinates(A); EtapeOperation etapeOperation = new EtapeOperation(_contextTrip); var etapeDe = etapeOperation.GetByCoordinates(voyage.ID, geocodingDe.Item1, geocodingDe.Item2, true); var etapeA = etapeOperation.GetByCoordinates(voyage.ID, geocodingA.Item1, geocodingA.Item2, false); return(GetPrixVoyage(voyage, etapeDe, etapeA)); }
public void Add(VOYAGE voyage, string donnee) { var parcoursVoyage = JsonConvert.DeserializeObject <Result>(donnee); int index = 1; int indexVoyage = 1; var voyageEtape = new EtapeOperation(_context); foreach (Legs legs in parcoursVoyage.Routes.First().listeLegs) { var etapeDe = voyageEtape.GetAll().SingleOrDefault(p => p.ID_VOYAGE == voyage.ID && p.ORDRE == index); var etapeA = voyageEtape.GetAll().SingleOrDefault(p => p.ID_VOYAGE == voyage.ID && p.ORDRE == index + 1); if (etapeA == null) { etapeA = voyageEtape.GetAll().SingleOrDefault(p => p.ID_VOYAGE == voyage.ID && p.ORDRE == 99999); } int indexStep = 1; foreach (var step in legs.ListeSteps) { _context.VOYAGE_GUIDAGE.Add(new VOYAGE_GUIDAGE() { ID_VOYAGE_ETAPE_DE = etapeDe.ID, ID_VOYAGE_ETAPE_A = etapeA.ID, ORDRE_ETAPE = indexStep, ORDRE_VOYAGE = indexVoyage, COORD_X = step.StartLocation.CoordX, COORD_Y = step.StartLocation.CoordY, DURATION = step.Duration.Text, DURATION_SEC = step.Duration.DureeEnSec, DIRECTION = step.Instructions, DISTANCE = step.Distance.Text, DISTANCE_M = step.Distance.DureeEnSec }); indexStep++; indexVoyage++; } index++; } }