Exemple #1
0
        public IActionResult GetAthletes(string uniqueDeviceId = null)
        {
            try
            {
                if (uniqueDeviceId != null)
                {
                    // Validate the device exists
                    if (!_deviceRepository.DeviceExists(uniqueDeviceId))
                    {
                        return(NotFound());
                    }

                    var athleteEntities = _athleteRepository.GetAthletesByDevice(uniqueDeviceId);
                    var results         = _mapper.Map <IEnumerable <AthleteDto> >(athleteEntities);

                    return(Ok(results));
                }
                else
                {
                    var athleteEntities = _athleteRepository.GetAthletes();
                    var results         = _mapper.Map <IEnumerable <AthleteDto> >(athleteEntities);

                    return(Ok(results));
                }
            }
            catch (Exception ex)
            {
                _logger.LogCritical($"Exception while getting athletes", ex);
                return(StatusCode(500, "A problem happened while handling your request"));
            }
        }
Exemple #2
0
 public async Task <ActionResult> GetAthletes()
 {
     return(Ok(await _athleteRepository.GetAthletes()));
 }