public void Update(Ingredients entity) // este está mal hecho. { var result = _context.Ingredients.SingleOrDefault(b => b.IngredientsId == entity.IngredientsId); if (result != null) { try {// solo hay que poner esta línea. _context.Entry(result).CurrentValues.SetValues(entity); } catch (Exception ex) { throw new Exception("No se ha encontrado la pizza que quiere actualizar"); } } }
public void Update(Ingredients entity) { var result = _context.Ingredients.SingleOrDefault(b => b.IngredientsId == entity.IngredientsId); if (result != null) { try { _context.Entry(result).CurrentValues.SetValues(entity); } catch (Exception ex) { throw new Exception("No esta disponible la pizza que desea"); } } }
public void Delete(Ingredients entity) { _context.Ingredients.Remove(entity); }
public void Add(Ingredients entity) { _context.Ingredients.Add(entity); }