Пример #1
0
        public async Task <IActionResult> RunAsync(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]
            HttpRequest req,
            ILogger log)
        {
            var name = req.Query["chatName"];

            if (string.IsNullOrEmpty(name))
            {
                return(new BadRequestObjectResult("chatName is empty"));
            }

            var result = await _statsService.GetChatStatAsync(name);

            if (!result.Any())
            {
                return(new NotFoundObjectResult($"No stats found for chat {name}"));
            }

            var jResult = JsonConvert.SerializeObject(result);

            return(new OkObjectResult(jResult));
        }