コード例 #1
0
 public IActionResult Post([FromBody] Recipe recipe)
 {
     try
     {
         manager.Create(recipe);
     }
     catch (MySqlException ex)
     {
         return(StatusCode(409));
     }
     return(Ok());
 }
コード例 #2
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));
        }
コード例 #3
0
        public IHttpActionResult Post(Recipe recipe)
        {
            try
            {
                var mng = new RecipeManager();
                mng.Create(recipe);

                apiResp = new ApiResponse
                {
                    Message = "Haz finalizado la compra exitosamente."
                };

                return(Ok(apiResp));
            }
            catch (BussinessException bex)
            {
                return(InternalServerError(new Exception(bex.ExceptionId + "-" + bex.AppMessage.Message)));
            }
        }