private void OnAddCommandExecute() { IsDialogOpen = false; newProduct = new Product { Id = Guid.NewGuid(), Name = NewProductName, Description = NewProductDescription, ProductCategory = NewProductCategory }; Products.Add(newProduct); _productsRepository.AddProduct(newProduct); _productsRepository.Save(); RecipeProduct recipeProduct = new RecipeProduct { Id = Guid.NewGuid(), RecipeId = SelectedRecipe.Id, ProductId = newProduct.Id }; SelectedRecipe.RecipeProducts.Add(recipeProduct); SelectedRecipeProductLookups.Add(new RecipeProductLookup { ProductId = newProduct.Id, RecipeProductId = recipeProduct.Id, ProductName = newProduct.Name }); }
private void OnAddRecipeProduct() { if (SelectedRecipe != null && SelectedSearchBoxProduct != null && !SelectedRecipeProductLookups.Where(srpl => srpl.ProductId == SelectedSearchBoxProduct.Id).Any()) { if (SelectedSearchBoxProduct.Id.Equals(Guid.Parse("00000000-0000-0000-0000-000000000000"))) { return; } RecipeProduct recipeProduct = new RecipeProduct { Id = Guid.NewGuid(), RecipeId = SelectedRecipe.Id, ProductId = SelectedSearchBoxProduct.Id }; SelectedRecipe.RecipeProducts.Add(recipeProduct); SelectedRecipeProductLookups.Add(new RecipeProductLookup { ProductId = SelectedSearchBoxProduct.Id, ProductName = SelectedSearchBoxProduct.Name, RecipeProductId = recipeProduct.Id }); OnPropertyChanged(); } ClearSelectedProductUserInput(); }
private void OnAddRecipeProduct() { if (SelectedSearchBoxProduct != null && !SelectedRecipeProductLookups.Where(srpl => srpl.ProductId == SelectedSearchBoxProduct.Id).Any()) { RecipeProduct recipeProduct = new RecipeProduct { Id = Guid.NewGuid(), RecipeId = SelectedRecipe.Id, ProductId = SelectedSearchBoxProduct.Id }; SelectedRecipe.RecipeProducts.Add(recipeProduct); SelectedRecipeProductLookups.Add(new RecipeProductLookup { ProductId = SelectedSearchBoxProduct.Id, ProductName = SelectedSearchBoxProduct.Name, RecipeProductId = recipeProduct.Id }); OnPropertyChanged(); } }