public async Task SaveAsync(Recipe recipe)
        {
            var isNew = recipe.Id == default(long);

            _context.Entry(recipe).State = isNew ? EntityState.Added : EntityState.Modified;

            await _context.SaveChangesAsync();
        }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "Id,Name")] Foodstuff foodstuff)
 {
     if (ModelState.IsValid)
     {
         db.Entry(foodstuff).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(foodstuff));
 }