Example #1
0
        //add new routes
        public async Task Add(Guid userid, string name, double startLatitiude, double endLatitiude, double startLongitiude, double endLongitiude)
        {
            var driver = await _driverRepository.Get(userid);

            if (driver == null)
            {
                throw new Exception("Driver with user ID: " + userid + " not exist");
            }

            var StartAddress = await _manager.GetAddres(startLatitiude, startLongitiude);

            var EndAddress = await _manager.GetAddres(endLatitiude, endLongitiude);

            var start = Node.Create(StartAddress, startLatitiude, startLongitiude);

            var end = Node.Create(EndAddress, endLatitiude, endLongitiude);


            var distance = _manager.CalculateDistance(startLatitiude, startLongitiude, endLatitiude, endLongitiude);

            driver.AddRoute(name, start, end, distance);
            await _driverRepository.Udpate(driver);
        }