@RequestMapping(method = RequestMethod.POST)
  public String create(@Valid Recipe recipe, BindingResult result) {
    if (result.hasErrors()) return "recipes/new";

    recipeRepository.save(recipe);
    return "redirect:/recipes";
  }
  @RequestMapping(value = "{id}", method = RequestMethod.PUT)
  public String update(@PathVariable Long id, @Valid Recipe recipe, BindingResult result) {
    if (result.hasErrors()) return "recipes/edit";

    recipe.setId(id);
    recipeRepository.merge(recipe);
    return String.format("redirect:/recipes/%s", id);
  }
 @RequestMapping(value = "{id}", method = RequestMethod.DELETE)
 public String destroy(@PathVariable Long id) {
   Recipe recipe = recipeRepository.find(id);
   recipeRepository.destroy(recipe);
   return "redirect:/recipes";
 }
 @RequestMapping(value = "{id}/edit", method = RequestMethod.GET)
 public String edit(@PathVariable Long id, Model model) {
   Recipe recipe = recipeRepository.find(id);
   model.addAttribute("recipe", recipe);
   return "recipes/edit";
 }
 @RequestMapping(method = RequestMethod.GET)
 public String index(Model model) {
   model.addAttribute("recipes", recipeRepository.find());
   return "recipes/index";
 }