public void AddIngredient(Library.Ingredient ingredient) { Ingredient i = new Ingredient { Name = ingredient.Name }; db.Ingredient.Add(i); db.SaveChanges(); ingredient.IngredientId = i.IngredientId; }
public bool UpdateIngredient(Library.Ingredient ingredient) { //_db.Entry(_db.Restaurant.Find(restaurant.Id)).CurrentValues.SetValues(Mapper.Map(restaurant)); var temp = db.Ingredient.Find(ingredient.IngredientId); if (temp != null) { db.Entry(temp).CurrentValues.SetValues(new Ingredient { IngredientId = ingredient.IngredientId, Name = ingredient.Name }); db.SaveChanges(); return(true); } return(false); }
public static ModelIngredient Map(Library.Ingredient ingredient) => new ModelIngredient { IngredientId = ingredient.IngredientId, Name = ingredient.Name };
public static Ingredient Map(Library.Ingredient otherIngredient) => new Ingredient { Name = otherIngredient.Name, Quantity = otherIngredient.Quantity, Type = otherIngredient.Type };
public static Ingredient Map(Library.Ingredient ingredient) => new Ingredient { //IngredientId = ingredient.IngredientId, Name = ingredient.Name };