public HttpResponseMessage EditRecipe([FromUri]int id, RecipeModel model,
            [ValueProvider(typeof(HeaderValueProviderFactory<string>))]
            string accessToken)
        {
            return this.ExecuteOperationAndHandleExceptions(() =>
            {
                var context = new RecipeContext();

                var user = this.GetUserByAccessToken(accessToken, context);

                this.ValidateRecipe(model);

                var recipeEntity = this.GetRecipeById(id, context);

                recipeEntity.Name = model.Name;
                recipeEntity.Products = model.Products;
                recipeEntity.CookingSteps = model.CookingSteps;
                recipeEntity.ImagePath = model.ImagePath;

                context.SaveChanges();

                var responseModel = new RecipeCreatedModel()
                {
                    Id = recipeEntity.RecepieId
                };

                var response = this.Request.CreateResponse(HttpStatusCode.Created, responseModel);

                return response;
            });
        }
        public RecipeModel Get([FromUri]int id)
        {
            return this.ExecuteOperationAndHandleExceptions(() =>
            {
                var context = new RecipeContext();

                var recipe = this.GetRecipeById(id, context);

                var recipeModel = new RecipeModel() {
                    Id = recipe.RecepieId,
                    Name = recipe.Name,
                    CookingSteps = recipe.CookingSteps,
                    Products = recipe.Products,
                    ImagePath = recipe.ImagePath
                };
                return recipeModel;
            });
        }
 private void ValidateRecipe(RecipeModel model)
 {
     if (String.IsNullOrEmpty(model.Name) ||
         String.IsNullOrEmpty(model.CookingSteps) ||
         String.IsNullOrEmpty(model.Products) ||
         String.IsNullOrEmpty(model.ImagePath))
     {
         throw new ArgumentNullException("Invalid Recipe");
     }
 }