private Ingredient ConvertDbIngredient(DbIngredient dbIngredient) { return(new Ingredient { ProductId = dbIngredient.ProductId, RecipeId = dbIngredient.RecipeId, ProductName = dbIngredient.Product.Name, UnitQuantity = dbIngredient.UnitQuantity, UnitQuantityType = dbIngredient.UnitQuantityType }); }
public void Insert(IIngredient ingredient) { DbIngredient newIngredient = new DbIngredient { ProductId = ingredient.ProductId, RecipeId = ingredient.RecipeId, UnitQuantity = ingredient.UnitQuantity, UnitQuantityType = ingredient.UnitQuantityType }; using var context = new HomeAppDbContext(myDbOptions); context.Ingredients.Add(newIngredient); context.SaveChanges(); }