public ActionResult Edit([Bind(Include = "IngredientCategoryId,Name,Id")] IngredientCategory ingredientCategory) { if (ModelState.IsValid) { _ingredientCategoryService.Update(ingredientCategory); return(RedirectToAction("Index")); } return(View(ingredientCategory)); }
public async Task <IHttpActionResult> PutGroceryCategory(int id, IngredientCategoryModel ingredientCategoryModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != ingredientCategoryModel.Id) { return(BadRequest()); } var ingredientCategory = _ingredientCategoryService.GetById(id); ObjectFactory.Parse(ingredientCategoryModel, ingredientCategory); _ingredientCategoryService.Update(ingredientCategory); try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GroceryCategoryExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }