Esempio n. 1
0
        public static async Task <HttpResponseMessage> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = "bodymesurement")] HttpRequestMessage req,
            ILogger logger,
            [Inject] IWeightMeasurementService weightMeasurementService
            )
        {
            var json = await req.Content.ReadAsStringAsync();

            logger.LogInformation(json);

            var entity = WeightMesurementEntity.Parse(json);

            entity.InsertedTime = DateTime.UtcNow;

            logger.LogInformation($"weight={entity.Weight}, leanMass={entity.LeanMass}, fatMass={entity.FatMass}, fatPercent={entity.FatPercent}, mesuredAt={entity.MesuredAt}");

            await weightMeasurementService.AddData(entity);

            return(req.CreateResponse(HttpStatusCode.OK, JsonConvert.SerializeObject(entity)));
        }
 public async Task AddData(WeightMesurementEntity entity)
 {
     await weightMeasurementRepository.AddAsync(entity);
 }