Пример #1
0
        public async Task <IHttpActionResult> GetDirection([FromUri] TravelModel dto)
        {
            var direction = MAPS.GetDirection(dto.Origin, dto.Destiny);

            if (!direction.StatusOk)
            {
                throw new Exception("Rota não existe ou não foi encontrada");
            }

            return(Ok(new
            {
                direction.Distance,
                direction.Duration,
                direction.DurationValue,
                direction.Destiny,
                direction.Origin,
                StartAddress = new Locatization()
                {
                    Lat = direction.Start.Lat,
                    Long = direction.Start.Long,
                },
                EndAddress = new Locatization()
                {
                    Lat = direction.End.Lat,
                    Long = direction.End.Long,
                },
                direction.StatusOk,
                direction.Copyrights
            }));
        }
Пример #2
0
        public async Task <IHttpActionResult> GetMaps([FromUri] TravelModel dto)
        {
            var route = MAPS.SearchMap(dto.Origin, dto.Destiny);

            if (route.IsError)
            {
                throw new Exception("Rota não existe ou não foi encontrada");
            }

            return(Ok(new
            {
                route.Destiny,
                route.TotalKm,
                route.Duration,
                route.Origin,
            }));
        }