public static async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = "location")] HttpRequestMessage req, ILogger logger, [Inject] ILocationEnteredOrExitedService locationEnteredOrExitedService ) { var json = await req.Content.ReadAsStringAsync(); logger.LogInformation(json); var request = JsonConvert.DeserializeObject <LocationEnteredOrExitedRequest>(json); logger.LogInformation($"location={request.Location}, enteredOrExited={request.EnteredOrExited}"); var now = DateTime.UtcNow; var entity = new LocationEnteredOrExitedEntity(request.Location, now.Ticks.ToString()) { Location = request.Location, EnteredOrExited = request.EnteredOrExited, CreatedAt = now, }; await locationEnteredOrExitedService.AddAsync(entity); return(req.CreateResponse(HttpStatusCode.OK, $"Location={request.Location} EnteredOrExited={request.EnteredOrExited}")); }
public async Task AddAsync(LocationEnteredOrExitedEntity entity) { await locationEnteredOrExitedRepository.AddAsync(entity); }