private GetThermostatsRequest CreateGetThermostatsRequest(ThermostatToGetModel message, string bearerToken)
        {
            var request = _mapper.Map <GetThermostatsRequest>(message);

            request.BearerToken = bearerToken;
            return(request);
        }
 private void Given_ThermostatToGetModel(
     bool includeReadings = true,
     bool includeScenes   = true,
     bool includeSettings = true)
 {
     _message = new ThermostatToGetModel
     {
         CorrelationId   = _faker.Random.AlphaNumeric(15),
         IncludeReadings = includeReadings,
         IncludeScenes   = includeScenes,
         IncludeSettings = includeSettings
     };
 }
        public async Task <IEnumerable <ThermostatModel> > Handle(ThermostatToGetModel message)
        {
            _message = message;

            IEnumerable <Domain.Entities.Thermostat> thermostats = null;

            try
            {
                var bearerToken = await _authenticationService.GetBearerToken(message.CorrelationId);

                var request = CreateGetThermostatsRequest(message, bearerToken);
                thermostats = (await _thermostatProvider.GetThermostats(request)).ToList();
                var models = thermostats.Select(Transform);
                await StoreDomainEvent();

                return(models);
            }
            catch (Exception ex)
            {
                await StoreExceptionDomainEvent(ex, thermostats);

                throw;
            }
        }
        public async Task <IActionResult> Get(ThermostatToGetModel model)
        {
            var thermostatReadings = await _mediator.Send(model);

            return(Ok(thermostatReadings));
        }