Exemple #1
0
        private DistanceBetweenCities FindMinimumDistance(RouteList routeCities)
        {
            List <RouteBetweenCities> SortedList = routeCities.Routes.OrderBy(dvs => dvs.Distance).ToList();
            DistanceBetweenCities     distance   = new DistanceBetweenCities();

            distance.Distance = SortedList[0].Distance;
            distance.Path.AddRange(SortedList[0].Route.Select(c => c.ToString()));
            return(distance);
        }
Exemple #2
0
        public async Task <DistanceBetweenCities> FindMinimumDistanceByGraphID(int graphID, string town1, string town2)
        {
            RouteList routeCities = await FindRoutesByGraphID(graphID, town1, town2, 0);

            DistanceBetweenCities distanceBetweenCities = new DistanceBetweenCities();

            if (routeCities.Routes.Count > 0)
            {
                distanceBetweenCities = FindMinimumDistance(routeCities);
            }
            return(distanceBetweenCities);
        }
Exemple #3
0
        public async Task <ActionResult> PostAsync(int graphID, string town1, string town2)
        {
            try
            {
                DistanceBetweenCities minDistance = await _routeService.FindMinimumDistanceByGraphID(graphID, town1, town2);

                if (minDistance.Path.Count > 0)
                {
                    return(Ok(minDistance));
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception erroProcessamento)
            {
                _logger.LogError(erroProcessamento, "");
                return(BadRequest());
            }
        }