Exemple #1
0
        public async Task <WeatherForecast> Execute(Guid id)
        {
            var query  = new GetWeatherForecastByIdQuery(id);
            var entity = await _queryDispatcher.Execute <GetWeatherForecastByIdQuery, WeatherForecastEntity>(query);

            if (entity == null)
            {
                throw new NotFoundException($"No weather forecast found with ID = '{id}'.");
            }

            return(_mapper.Map <WeatherForecastEntity, WeatherForecast>(entity));
        }
Exemple #2
0
        public async Task Execute(Guid id, UpdateWeatherForecastRequest input, string username)
        {
            var query  = new GetWeatherForecastByIdQuery(id);
            var entity = await _queryDispatcher.Execute <GetWeatherForecastByIdQuery, WeatherForecastEntity>(query);

            if (entity == null)
            {
                throw new NotFoundException($"No weather forecast found with ID = '{id}'.");
            }

            entity.Temperature = input.TemperatureInCelsius;
            entity.Date        = input.Date;
            entity.Summary     = input.Summary;

            var command = new UpdateWeatherForecastCommand(entity, username);
            await _commandDispatcher.Execute(command);
        }