public IActionResult Post([FromBody] Recipe recipe) { try { manager.Create(recipe); } catch (MySqlException ex) { return(StatusCode(409)); } return(Ok()); }
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)); }
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))); } }