public ActionResult EditRecipeIngredientPost(RecipeIngredient recipeIngredient)
 {
     if (ModelState.IsValid)
     {
         _recipeIngredientService.Update(recipeIngredient);
         return(RedirectToAction("Index"));
     }
     PopulateSeletLists();
     return(View(recipeIngredient));
 }
示例#2
0
        public async Task <IHttpActionResult> PutRecipeIngredient(int id, RecipeIngredientModel recipeIngredientModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != recipeIngredientModel.Id)
            {
                return(BadRequest());
            }

            var recipeIngredient = _recipeIngredientService.GetRecipeIngredientById(id);

            ObjectFactory.Parse(recipeIngredientModel, recipeIngredient);

            _recipeIngredientService.Update(recipeIngredient);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RecipeIngredientExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }