Exemple #1
0
        /// <summary>
        /// this function will get data from api and then in case there are no results then will return
        /// to the main project that there are nothing to show
        /// </summary>
        /// <param name="distance">the distance the user wishes to travel by starship</param>
        /// <returns>it will return true if all calculations done and displayed or false in case of failure</returns>
        public bool ProcessData(decimal distance)
        {
            ///bringing data from the api
            starships ships   = _dataapi.getstarships();
            int       nbstops = 0;

            if (ships == null)
            {
                return(false);
            }

            ///checking if api has returned results
            if (ships.results.Count() != 0)
            {
                ///looping the startships, calculating the number of stops and displaying the results
                foreach (starship ship in ships.results)
                {
                    ///calculating the number of stops
                    nbstops = _calc.getnumberofstops(distance, ship.MGLT, ship.consumables);
                    if (nbstops > -1)
                    {
                        ///displaying the results
                        _disp.displaylistshipandstop(ship, nbstops);
                    }
                }
            }
            return(true);
        }