コード例 #1
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
            ILogger logger,
            [Inject] IWithingsSleepService withingsSleepService
            )
        {
            logger.LogInformation("C# HTTP trigger function processed a request.");

            var json = await req.ReadAsStringAsync();

            logger.LogInformation(json);

            var withingsSleepRequest = JsonConvert.DeserializeObject <WighingsSleepRequest>(json);

            var date = DateTimeParser.ParseWithingsDate(withingsSleepRequest.DateAndTime);

            var now    = DateTime.UtcNow;
            var entity = new WithingsSleepEntity("withingsSleepEntity", now.Ticks.ToString())
            {
                Action       = withingsSleepRequest.Action,
                Date         = date.AddHours(-9), // jst -> utc
                InsertedTime = now,
            };

            logger.LogInformation($"action={entity.Action}, date={entity.Date}");

            await withingsSleepService.AddAsync(entity);

            return(new OkObjectResult($"action={entity.Action}, date={entity.Date}"));
        }
コード例 #2
0
        public async Task TestMethod1()
        {
            var withingsSleepService = GetWithingsSleepService();

            var now    = DateTime.UtcNow;
            var entity = new WithingsSleepEntity("WithingsSleepEntity", now.Ticks.ToString())
            {
                Action       = "test action",
                Date         = now,
                InsertedTime = now,
            };

            await withingsSleepService.AddAsync(entity);
        }
コード例 #3
0
 public async Task AddAsync(WithingsSleepEntity entity)
 {
     await withingsSleepRepository.AddAsync(entity);
 }