Ejemplo n.º 1
0
        public async Task <ActionResult <DashboardDto> > GetDashboardData([FromQuery] LatLonParameters latLonParameters)
        {
            BeachConditionsDto beachConditions = null;

            try
            {
                beachConditions = await _weatherService.GetBeachConditions();
            }
            catch (Exception e)
            {
                _logger.LogWarning("Beach Conditions could not be grabbed: " + e.Message);
            }

            var uvDto = await _weatherService.GetCurrentUVIndex(latLonParameters);

            var weatherData = await _weatherService.GetWeather(latLonParameters);

            var usersFromRepo = await _beachBuddyRepository.GetUsers();

            var dashboardDto = new DashboardDto
            {
                BeachConditions = beachConditions,
                DashboardUvDto  = _mapper.Map <DashboardUVDto>(uvDto),
                // Todo: this can be deleted
                // DashboardUvDto = new DashboardUVDto
                // {
                //   uv  = 8.3,
                //   uv_time = "2020-06-29T13:32:07.067Z",
                //   uv_max = 12.1,
                //   uv_max_time = "2020-06-29T16:32:07.067Z",
                //   safe_exposure_time = new SafeExposureTimeDto
                //   {
                //       st1 = 10,
                //       st2 = 20,
                //       st3 = 30,
                //       st4 = 40,
                //       st5 = 50,
                //       st6 = 60
                //   }
                // },
                WeatherInfo = weatherData,
                Users       = _mapper.Map <IEnumerable <UserDto> >(usersFromRepo),
            };

            return(Ok(dashboardDto));
        }
Ejemplo n.º 2
0
 public async Task <ActionResult <VisitBeachesDto> > GetWeather()
 {
     return(Ok(await _weatherService.GetBeachConditions()));
 }