示例#1
0
        public SearchResultDTO ClickCalculate(Parcel parcel, City source, City destination)
        {
            List <Edge> edges;
            List <City> cities;

            cities = MappingService.GetCities();
            edges  = MappingService.GetEdges(cities);    //context.GetAllEdges();

            Graph <City, string> graphPrice     = GraphFabric.CreateGraphPrice(cities, edges, "priceCost", parcel);
            Graph <City, string> graphTime      = GraphFabric.CreateGraphTime(cities, edges, "timeCost");
            Graph <City, string> graphPriceTime = GraphFabric.CreateGraphTime(cities, edges, "price times cost");

            RouteCalculatorService routeCalcPrice = new RouteCalculatorService(graphPrice);
            ShortestPathResult     resultPrice    = routeCalcPrice.CalculateShortestPath(source, destination);
            List <City>            pathPrice      = routeCalcPrice.GetCityPath(resultPrice);

            RouteCalculatorService routeCalcTime = new RouteCalculatorService(graphTime);
            ShortestPathResult     resultTime    = routeCalcPrice.CalculateShortestPath(source, destination);
            List <City>            pathTime      = routeCalcTime.GetCityPath(resultTime);

            RouteCalculatorService routePriceTime  = new RouteCalculatorService(graphPriceTime);
            ShortestPathResult     resultPriceTime = routeCalcPrice.CalculateShortestPath(source, destination);
            List <City>            pathPriceTime   = routeCalcTime.GetCityPath(resultPriceTime);

            this.SaveParcel(parcel);

            var cPath = new PathDTO()
            {
                Cities   = ReturnCityDtos(pathPrice),
                Duration = 42,
                Price    = resultPrice.Distance
            };

            var fPath = new PathDTO()
            {
                Cities   = ReturnCityDtos(pathTime),
                Duration = resultTime.Distance,
                Price    = 42
            };

            var bPath = new PathDTO()
            {
                Cities   = ReturnCityDtos(pathPriceTime),
                Duration = resultPriceTime.Distance,
                Price    = 42
            };

            return(new SearchResultDTO
            {
                Cheapest = cPath,
                Fastest = fPath,
                Best = bPath
            });
        }
示例#2
0
        protected override void Seed(DAL.TLContext context)
        {
            var cities = MappingService.GetCities();

            cities.ForEach(city => context.City.AddOrUpdate(city));

            var edges = MappingService.GetEdges(cities);

            edges.ForEach(edge => context.Edge.AddOrUpdate(edge));

            context.SaveChanges();
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.
        }