示例#1
0
        public MarsRoverHistoryResponse GetHistory()
        {
            MarsRoverHistoryResponse response = new MarsRoverHistoryResponse();

            try
            {
                List <RoverHistory> roverHistories = File.ReadAllLines(_reportPath)
                                                     .Skip(1)
                                                     .Select(v => RoverHistory.FromCsv(v))
                                                     .OrderByDescending(m => m.DateOfRequest)
                                                     .ToList();
                response.RoverHistories = roverHistories;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(response);
        }
示例#2
0
        public IActionResult History()
        {
            IList <RoverHistory> model = new List <RoverHistory>();

            try
            {
                MarsRoverHistoryResponse response = _clientService.GetHistory();
                if (response != null && response.RoverHistories.Count() > 0)
                {
                    foreach (RoverHistory _rover in response.RoverHistories)
                    {
                        model.Add(_rover);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.StackTrace);
            }
            return(View(model));
        }