public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = "thermohygrometer")] HttpRequest req, ILogger logger, [Inject] IThermohygrometerService thermohygrometerService ) { var json = await req.ReadAsStringAsync(); logger.LogInformation(json); var requestData = JsonConvert.DeserializeObject <RequestThermohygrometer>(json); var info = $"Temperature={requestData.Temperature}, Humidity={requestData.Humidity}, Location={requestData.Location}, MesuredAt={requestData.MesuredAt}"; logger.LogInformation(info); var entity = new ThermohygrometerEntity(requestData.Location, requestData.MesuredAt.Ticks.ToString().ToString()) { Location = requestData.Location, Temperature = requestData.Temperature, Humidity = requestData.Humidity, MesuredAt = requestData.MesuredAt, }; await thermohygrometerService.AddData(entity); return(new OkObjectResult(info)); }
public Task AddData(ThermohygrometerEntity entity) { return(thermohygrometerRepository.AddAsync(entity)); }