//
        // GET: /BlankRecipeEditor/Open
        public ActionResult Open(int recipeId)
        {
            Recipe recipe;
            if (recipeId > 0)
            {
                // Existing recipe is being edited.
                // Validate that only the initial author of the recipe can edit it.
                recipe = _recipeRepo.GetRecipe(recipeId);

                string currentAuthorId =  this.GetUserNameIdentifier();
                if (recipe.AuthorId != currentAuthorId)
                {
                    return View("WrongAuthor", recipe);
                }
            }
            else
            {
                recipe = new TextRecipe
                             {
                                 Author = this.GetUserName(),
                                 AuthorId = this.GetUserNameIdentifier(),
                                 CreationDate = DateTime.Now
                             };
                _recipeRepo.SetRecipe(recipe);
            }

            return View(recipe);
        }
        public JsonResult Save(TextRecipe recipe)
        {
            recipe.Author = this.GetUserName();
            recipe.AuthorId = this.GetUserNameIdentifier();

            // The recipe must belong to the current user.
            string oldAuthorId = _recipeRepo.GetRecipe(recipe.Id).AuthorId;
            if (oldAuthorId != recipe.AuthorId)
            {
                throw new InvalidOperationException("Invalid author. The author must not change.");
            }

            _recipeRepo.SetRecipe(recipe);

            Thread.Sleep(1000);
            //  throw new ArgumentException("Bad things happended");
            return Json(recipe);
        }