예제 #1
0
        public async Task <IActionResult> Create(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "recipe")] HttpRequest req,
            ILogger log,
            ClaimsPrincipal user)
        {
            if (!_authorizationManager.CanManageRecipes(user))
            {
                return(new ForbidResult());
            }

            var data = await req.ReadAsStringAsync();

            var recipeData = JsonConvert.DeserializeObject <Recipe>(data);

            var result = await _manager.Create(recipeData);

            return(new OkObjectResult(result));
        }