async Task <FridgeProduct> IService <FridgeProduct, int> .Update(FridgeProduct entity)
        {
            var FridgeProduct = await db.FridgeProducts.Update(entity);

            return(FridgeProduct);
        }
Пример #2
0
        private FoodNetDbContext GetContextWithData()
        {
            var options = new DbContextOptionsBuilder <FoodNetDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;
            var ctx = new FoodNetDbContext(options);

            user1 = new User
            {
                Id    = Guid.Parse("B71DBC28-6A02-47B1-8A2A-C6A5BFCD78AD"),
                Name  = "TestUser1",
                Email = "*****@*****.**"
            };
            fridge1 = new Fridge
            {
                Id     = Guid.NewGuid(),
                UserId = Guid.Parse("B71DBC28-6A02-47B1-8A2A-C6A5BFCD78AD")
            };

            user2 = new User
            {
                Id    = secondUserGuid,
                Name  = "TestUser2",
                Email = "*****@*****.**"
            };
            fridge2 = new Fridge
            {
                Id     = Guid.NewGuid(),
                UserId = Guid.Parse("B71DBC28-AAAA-47B1-8A2A-C6A5BFCD78AD")
            };

            productCategory1 = new ProductCategory
            {
                Id   = Guid.Parse("A5ADA8E6-04E1-49CA-A701-1265E216D69A"),
                Name = "Product Category 1"
            };
            productCategory2 = new ProductCategory
            {
                Id   = Guid.Parse("94CAE204-3337-43FA-8C0E-24C927BACAC4"),
                Name = "Product Category 2"
            };
            productCategory3 = new ProductCategory
            {
                Id   = Guid.NewGuid(),
                Name = "Product Category 3"
            };

            product1 = new BasicProduct
            {
                Id                = Guid.Parse("9C750539-3CA6-4239-941F-805B81C38CD4"),
                Name              = "Salmon",
                Description       = "",
                ProductCategoryId = productCategory1.Id,
                UserId            = Guid.Parse("B71DBC28-6A02-47B1-8A2A-C6A5BFCD78AD")
            };
            product2 = new BasicProduct
            {
                Id                = Guid.Parse("9D8FAC6F-C194-44E5-A6D5-B6F6DBDEBBD0"),
                Name              = "Mustard",
                Description       = "",
                ProductCategoryId = productCategory1.Id,
                UserId            = Guid.Parse("B71DBC28-6A02-47B1-8A2A-C6A5BFCD78AD")
            };
            product3 = new BasicProduct
            {
                Id                = Guid.Parse("F1F5610D-F065-46D8-9208-D7D1A0CB8C27"),
                Name              = "Brown Sugar",
                Description       = "",
                ProductCategoryId = productCategory1.Id,
                UserId            = Guid.Parse("B71DBC28-6A02-47B1-8A2A-C6A5BFCD78AD")
            };

            product4 = new BasicProduct
            {
                Id                = Guid.Parse("06BBED64-A505-492C-889B-472F7DAB0FAA"),
                Name              = "Butter",
                Description       = "",
                ProductCategoryId = productCategory2.Id,
                UserId            = secondUserGuid
            };
            product5 = new BasicProduct
            {
                Id                = Guid.Parse("270B1180-45C6-4EE1-BC06-4819743859DC"),
                Name              = "Cream",
                Description       = "",
                ProductCategoryId = productCategory2.Id,
                UserId            = secondUserGuid
            };
            product6 = new BasicProduct
            {
                Id                = Guid.Parse("002D754C-176B-4324-A42E-2DC32369074D"),
                Name              = "Eggs",
                Description       = "",
                ProductCategoryId = productCategory2.Id,
                UserId            = secondUserGuid
            };

            newProduct1 = new NewProduct
            {
                Id                = Guid.NewGuid(),
                Name              = "New product 1",
                Description       = "",
                ProductCategoryId = productCategory1.Id,
                UserId            = firstUserGuid
            };
            newProduct2 = new NewProduct
            {
                Id                = Guid.NewGuid(),
                Name              = "New product 2",
                Description       = "",
                ProductCategoryId = productCategory2.Id,
                UserId            = secondUserGuid
            };
            newProduct3 = new NewProduct
            {
                Id                = Guid.NewGuid(),
                Name              = "New product 3",
                Description       = "",
                ProductCategoryId = productCategory2.Id,
                UserId            = secondUserGuid
            };

            recipe1 = new Recipe
            {
                Id          = Guid.Parse("83BD2A25-83EA-47D0-9B7B-0E4D528CF8C2"),
                Description = "",
                Title       = "Salmon recipe",
                UserId      = firstUserGuid
            };
            recipe2 = new Recipe
            {
                Id          = Guid.Parse("F795B317-DB3B-469F-9891-62C5CCC9DF5D"),
                Description = "",
                Title       = "Scrambled eggs",
                UserId      = secondUserGuid
            };
            recipe3 = new Recipe
            {
                Id          = Guid.NewGuid(),
                Description = "",
                Title       = "Recipe 3",
                UserId      = firstUserGuid
            };

            recipe1Product1 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                RecipeId  = recipe1.Id,
                ProductId = product1.Id
            };
            recipe1Product2 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                RecipeId  = recipe1.Id,
                ProductId = product2.Id
            };
            recipe1Product3 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                RecipeId  = recipe1.Id,
                ProductId = product3.Id
            };
            recipe2Product4 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                RecipeId  = recipe2.Id,
                ProductId = product4.Id
            };
            recipe2Product5 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                RecipeId  = recipe2.Id,
                ProductId = product5.Id
            };
            recipe2Product6 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                RecipeId  = recipe2.Id,
                ProductId = product6.Id
            };
            recipe3Product6 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                RecipeId  = recipe3.Id,
                ProductId = product6.Id
            };

            fridge1Product1 = new FridgeProduct
            {
                Id        = Guid.NewGuid(),
                FridgeId  = fridge1.Id,
                ProductId = product1.Id
            };
            fridge1Product2 = new FridgeProduct
            {
                Id        = Guid.NewGuid(),
                FridgeId  = fridge1.Id,
                ProductId = product2.Id
            };
            fridge1Product3 = new FridgeProduct
            {
                Id        = Guid.NewGuid(),
                FridgeId  = fridge1.Id,
                ProductId = product3.Id
            };
            fridge1Product4 = new FridgeProduct
            {
                Id        = Guid.NewGuid(),
                FridgeId  = fridge1.Id,
                ProductId = product4.Id
            };
            fridge1Product5 = new FridgeProduct
            {
                Id        = Guid.NewGuid(),
                FridgeId  = fridge1.Id,
                ProductId = product5.Id
            };
            fridge1Product6 = new FridgeProduct
            {
                Id        = Guid.NewGuid(),
                FridgeId  = fridge1.Id,
                ProductId = product6.Id
            };

            tag1 = new Tag
            {
                Id         = Guid.NewGuid(),
                Text       = "tag1",
                RecipeTags = new List <RecipeTag>()
            };
            tag2 = new Tag
            {
                Id         = Guid.NewGuid(),
                Text       = "tag2",
                RecipeTags = new List <RecipeTag>()
            };
            tag3 = new Tag
            {
                Id         = Guid.NewGuid(),
                Text       = "tag3",
                RecipeTags = new List <RecipeTag>()
            };
            tag4 = new Tag
            {
                Id         = Guid.NewGuid(),
                Text       = "tag4",
                RecipeTags = new List <RecipeTag>()
            };

            recipe1tag1 = new RecipeTag
            {
                Id       = Guid.NewGuid(),
                TagId    = tag1.Id,
                RecipeId = recipe1.Id
            };
            recipe1tag2 = new RecipeTag
            {
                Id       = Guid.NewGuid(),
                TagId    = tag2.Id,
                RecipeId = recipe1.Id
            };
            recipe2tag2 = new RecipeTag
            {
                Id       = Guid.NewGuid(),
                TagId    = tag2.Id,
                RecipeId = recipe2.Id
            };
            recipe2tag3 = new RecipeTag
            {
                Id       = Guid.NewGuid(),
                TagId    = tag1.Id,
                RecipeId = recipe1.Id
            };
            recipe3tag2 = new RecipeTag
            {
                Id       = Guid.NewGuid(),
                TagId    = tag2.Id,
                RecipeId = recipe3.Id
            };

            ctx.ProductCategories.Add(productCategory1);
            ctx.ProductCategories.Add(productCategory2);
            ctx.ProductCategories.Add(productCategory3);

            ctx.Products.Add(product1);
            ctx.Products.Add(product2);
            ctx.Products.Add(product3);
            ctx.Products.Add(product4);
            ctx.Products.Add(product5);
            ctx.Products.Add(product6);

            ctx.Products.Add(newProduct1);
            ctx.Products.Add(newProduct2);
            ctx.Products.Add(newProduct3);

            ctx.Recipes.Add(recipe1);
            ctx.Recipes.Add(recipe2);
            ctx.Recipes.Add(recipe3);

            ctx.RecipeProducts.Add(recipe1Product1);
            ctx.RecipeProducts.Add(recipe1Product2);
            ctx.RecipeProducts.Add(recipe1Product3);
            ctx.RecipeProducts.Add(recipe2Product4);
            ctx.RecipeProducts.Add(recipe2Product5);
            ctx.RecipeProducts.Add(recipe2Product6);
            ctx.RecipeProducts.Add(recipe3Product6);

            ctx.FridgeProducts.Add(fridge1Product1);
            ctx.FridgeProducts.Add(fridge1Product2);
            ctx.FridgeProducts.Add(fridge1Product3);
            ctx.FridgeProducts.Add(fridge1Product4);
            ctx.FridgeProducts.Add(fridge1Product5);
            ctx.FridgeProducts.Add(fridge1Product6);

            ctx.Tags.Add(tag1);
            ctx.Tags.Add(tag2);
            ctx.Tags.Add(tag3);
            ctx.Tags.Add(tag4);

            ctx.RecipeTags.Add(recipe1tag1);
            ctx.RecipeTags.Add(recipe1tag2);
            ctx.RecipeTags.Add(recipe2tag2);
            ctx.RecipeTags.Add(recipe2tag3);
            ctx.RecipeTags.Add(recipe3tag2);

            ctx.Users.Add(user1);
            ctx.Users.Add(user2);

            ctx.Fridges.Add(fridge1);
            ctx.Fridges.Add(fridge2);

            ctx.SaveChanges();

            return(ctx);
        }
Пример #3
0
        private void InitFields()
        {
            user1 = new User
            {
                Id    = Guid.Parse("B71DBC28-6A02-47B1-8A2A-C6A5BFCD78AD"),
                Name  = "TestUser1",
                Email = "*****@*****.**"
            };
            fridge1 = new Fridge
            {
                Id     = Guid.NewGuid(),
                UserId = Guid.Parse("B71DBC28-6A02-47B1-8A2A-C6A5BFCD78AD")
            };

            user2 = new User
            {
                Id    = Guid.Parse("B71DBC28-6A02-47B1-8A2A-C6A5BFCD78AD"),
                Name  = "TestUser2",
                Email = "*****@*****.**"
            };
            fridge2 = new Fridge
            {
                Id     = Guid.NewGuid(),
                UserId = Guid.Parse("B71DBC28-AAAA-47B1-8A2A-C6A5BFCD78AD")
            };

            productCategory1 = new ProductCategory
            {
                Id   = Guid.Parse("A5ADA8E6-04E1-49CA-A701-1265E216D69A"),
                Name = "Product Category 1"
            };
            productCategory2 = new ProductCategory
            {
                Id   = Guid.Parse("94CAE204-3337-43FA-8C0E-24C927BACAC4"),
                Name = "Product Category 2"
            };
            productCategory3 = new ProductCategory
            {
                Id   = Guid.NewGuid(),
                Name = "Product Category 3"
            };

            product1 = new BasicProduct
            {
                Id                = Guid.Parse("9C750539-3CA6-4239-941F-805B81C38CD4"),
                Name              = "Salmon",
                Description       = "",
                ProductCategoryId = productCategory1.Id,
                UserId            = Guid.Parse("B71DBC28-6A02-47B1-8A2A-C6A5BFCD78AD")
            };
            product2 = new BasicProduct
            {
                Id                = Guid.Parse("9D8FAC6F-C194-44E5-A6D5-B6F6DBDEBBD0"),
                Name              = "Mustard",
                Description       = "",
                ProductCategoryId = productCategory1.Id,
                UserId            = Guid.Parse("B71DBC28-6A02-47B1-8A2A-C6A5BFCD78AD")
            };
            product3 = new BasicProduct
            {
                Id                = Guid.Parse("F1F5610D-F065-46D8-9208-D7D1A0CB8C27"),
                Name              = "Brown Sugar",
                Description       = "",
                ProductCategoryId = productCategory1.Id,
                UserId            = Guid.Parse("B71DBC28-6A02-47B1-8A2A-C6A5BFCD78AD")
            };

            product4 = new BasicProduct
            {
                Id                = Guid.Parse("06BBED64-A505-492C-889B-472F7DAB0FAA"),
                Name              = "Butter",
                Description       = "",
                ProductCategoryId = productCategory2.Id,
                UserId            = secondUserGuid
            };
            product5 = new BasicProduct
            {
                Id                = Guid.Parse("270B1180-45C6-4EE1-BC06-4819743859DC"),
                Name              = "Cream",
                Description       = "",
                ProductCategoryId = productCategory2.Id,
                UserId            = secondUserGuid
            };
            product6 = new BasicProduct
            {
                Id                = Guid.Parse("002D754C-176B-4324-A42E-2DC32369074D"),
                Name              = "Eggs",
                Description       = "",
                ProductCategoryId = productCategory2.Id,
                UserId            = secondUserGuid
            };

            newProduct1 = new NewProduct
            {
                Id                = Guid.NewGuid(),
                Name              = "New product 1",
                Description       = "",
                ProductCategoryId = productCategory1.Id,
                UserId            = firstUserGuid
            };
            newProduct2 = new NewProduct
            {
                Id                = Guid.NewGuid(),
                Name              = "New product 2",
                Description       = "",
                ProductCategoryId = productCategory2.Id,
                UserId            = secondUserGuid
            };
            newProduct3 = new NewProduct
            {
                Id                = Guid.NewGuid(),
                Name              = "New product 3",
                Description       = "",
                ProductCategoryId = productCategory2.Id,
                UserId            = secondUserGuid
            };

            recipe1 = new Recipe
            {
                Id          = Guid.Parse("83BD2A25-83EA-47D0-9B7B-0E4D528CF8C2"),
                Description = "",
                Title       = "Salmon recipe",
                UserId      = Guid.Parse("B71DBC28-6A02-47B1-8A2A-C6A5BFCD78AD")
            };
            recipe2 = new Recipe
            {
                Id          = Guid.Parse("F795B317-DB3B-469F-9891-62C5CCC9DF5D"),
                Description = "",
                Title       = "Scrambled eggs",
                UserId      = Guid.Parse("B71DBC28-6A02-47B1-8A2A-C6A5BFCD78AD")
            };

            recipe1Product1 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                RecipeId  = recipe1.Id,
                ProductId = product1.Id
            };
            recipe1Product2 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                RecipeId  = recipe1.Id,
                ProductId = product2.Id
            };
            recipe1Product3 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                RecipeId  = recipe1.Id,
                ProductId = product3.Id
            };
            recipe2Product4 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                RecipeId  = recipe2.Id,
                ProductId = product4.Id
            };
            recipe2Product5 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                RecipeId  = recipe2.Id,
                ProductId = product5.Id
            };
            recipe2Product6 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                RecipeId  = recipe2.Id,
                ProductId = product6.Id
            };

            fridge1Product1 = new FridgeProduct
            {
                Id        = Guid.NewGuid(),
                FridgeId  = fridge1.Id,
                ProductId = product1.Id
            };
            fridge1Product2 = new FridgeProduct
            {
                Id        = Guid.NewGuid(),
                FridgeId  = fridge1.Id,
                ProductId = product2.Id
            };
            fridge1Product3 = new FridgeProduct
            {
                Id        = Guid.NewGuid(),
                FridgeId  = fridge1.Id,
                ProductId = product3.Id
            };
            fridge1Product4 = new FridgeProduct
            {
                Id        = Guid.NewGuid(),
                FridgeId  = fridge1.Id,
                ProductId = product4.Id
            };
            fridge1Product5 = new FridgeProduct
            {
                Id        = Guid.NewGuid(),
                FridgeId  = fridge1.Id,
                ProductId = product5.Id
            };
            fridge1Product6 = new FridgeProduct
            {
                Id        = Guid.NewGuid(),
                FridgeId  = fridge1.Id,
                ProductId = product6.Id
            };

            tag1 = new Tag
            {
                Id         = Guid.NewGuid(),
                Text       = "tag1",
                RecipeTags = new List <RecipeTag>()
            };
            tag2 = new Tag
            {
                Id         = Guid.NewGuid(),
                Text       = "tag2",
                RecipeTags = new List <RecipeTag>()
            };
            tag3 = new Tag
            {
                Id         = Guid.NewGuid(),
                Text       = "tag3",
                RecipeTags = new List <RecipeTag>()
            };

            recipe1tag1 = new RecipeTag
            {
                Id       = Guid.NewGuid(),
                TagId    = tag1.Id,
                RecipeId = recipe1.Id
            };
            recipe1tag2 = new RecipeTag
            {
                Id       = Guid.NewGuid(),
                TagId    = tag1.Id,
                RecipeId = recipe1.Id
            };
            recipe2tag3 = new RecipeTag
            {
                Id       = Guid.NewGuid(),
                TagId    = tag1.Id,
                RecipeId = recipe1.Id
            };

            recipe1.RecipeProducts = new List <RecipeProduct>
            {
                recipe1Product1,
                recipe1Product2,
                recipe1Product3
            };
            recipe1.RecipeTags = new List <RecipeTag> {
                recipe1tag1,
                recipe1tag2
            };

            recipe2.RecipeProducts = new List <RecipeProduct>();
            recipe2.RecipeTags     = new List <RecipeTag>
            {
                recipe2tag3
            };

            tempUpdatingRecipe = new Recipe
            {
                RecipeProducts = new List <RecipeProduct>(),
                RecipeTags     = new List <RecipeTag> {
                }
            };

            recipesList = new List <Recipe>
            {
                recipe1,
                recipe2
            };

            productsList = new List <Product> {
                product1, product2, product3, product4, product5, product6
            };

            poorProductsRepositoryMock = new Mock <IProductsRepository>();
            poorProductsRepositoryMock.Setup(pr => pr.GetProductById(It.IsAny <Guid>()))
            .Returns <Guid>(g => productsList.Where(p => p.Id == g).FirstOrDefault());

            tagsList = new List <Tag> {
                tag1, tag2, tag3
            };

            poorTagsRepositoryMock = new Mock <ITagsRepository>();
            poorTagsRepositoryMock.Setup(tr => tr.GetTagById(It.IsAny <Guid>()))
            .Returns <Guid>(g => tagsList.Where(t => t.Id == g).FirstOrDefault());

            recipesRepositoryMock = new Mock <IRecipesRepository>();
            recipesRepositoryMock.Setup(rr => rr.RemoveRecipeProduct(It.IsAny <RecipeProduct>()))
            .Callback <RecipeProduct>(rp =>
            {
                tempUpdatingRecipe.RecipeProducts.Remove(rp);
            });
            recipesRepositoryMock.Setup(rr => rr.AddProduct(It.IsAny <RecipeProduct>()))
            .Callback <RecipeProduct>(rp =>
            {
                tempUpdatingRecipe.RecipeProducts.Add(rp);
            });
            recipesRepositoryMock.Setup(rr => rr.RemoveProductById(It.IsAny <Guid>()))
            .Callback <Guid>(g =>
            {
                tempUpdatingRecipe.RecipeProducts.Remove(
                    tempUpdatingRecipe.RecipeProducts.Where(r => r.ProductId == g).FirstOrDefault());
            });
            recipesRepositoryMock.Setup(rr => rr.RemoveRecipeTag(It.IsAny <RecipeTag>()))
            .Callback <RecipeTag>(rt =>
            {
                tempUpdatingRecipe.RecipeTags.Remove(rt);
            });
            recipesRepositoryMock.Setup(rr => rr.RemoveTagById(It.IsAny <Guid>()))
            .Callback <Guid>(g =>
            {
                tempUpdatingRecipe.RecipeTags.Remove(
                    tempUpdatingRecipe.RecipeTags.Where(rt => rt.TagId == g).FirstOrDefault());
            });
            recipesRepositoryMock.Setup(rr => rr.AddTag(It.IsAny <RecipeTag>()))
            .Callback <RecipeTag>(rt =>
            {
                tempUpdatingRecipe.RecipeTags.Add(rt);
            });
            recipesRepositoryMock.Setup(rr => rr.GetRecipeById(It.IsAny <Guid>()))
            .Returns <Guid>(recipeId =>
            {
                return(tempUpdatingRecipe);
            });
            recipesRepositoryMock.Setup(rr => rr.ContainsProduct(It.IsAny <Guid>(), It.IsAny <Guid>()))
            .Returns <Guid, Guid>((recipeId, productId) =>
            {
                return(tempUpdatingRecipe.RecipeProducts.Any(rp => rp.ProductId == productId));
            });
            recipesRepositoryMock.Setup(rr => rr.ContainsTag(It.IsAny <Guid>(), It.IsAny <Guid>()))
            .Returns <Guid, Guid>((recipeId, tagId) =>
            {
                return(tempUpdatingRecipe.RecipeTags.Any(rt => rt.Id == tagId));
            });
        }
Пример #4
0
        private void setUpMocks()
        {
            fridgeProductForDbSetList = new List <FridgeProduct>();
            recipeProductForDbSetList = new List <RecipeProduct>();
            recipeForDbSetList        = new List <Recipe>();


            user = new User
            {
                Id      = Guid.NewGuid(),
                Fridges = new List <Fridge>()
            };

            recipe1 = new Recipe
            {
                Id             = Guid.NewGuid(),
                Title          = "Recipe1",
                UserId         = user.Id,
                Description    = "test",
                RecipeProducts = new List <RecipeProduct>()
            };
            recipe2 = new Recipe
            {
                Id             = Guid.NewGuid(),
                Title          = "Recipe2",
                UserId         = user.Id,
                Description    = "test",
                RecipeProducts = new List <RecipeProduct>()
            };
            recipe3 = new Recipe
            {
                Id             = Guid.NewGuid(),
                Title          = "Recipe3",
                UserId         = user.Id,
                Description    = "test",
                RecipeProducts = new List <RecipeProduct>()
            };
            recipe4 = new Recipe
            {
                Id             = Guid.NewGuid(),
                Title          = "Recipe4",
                UserId         = user.Id,
                Description    = "test",
                RecipeProducts = new List <RecipeProduct>()
            };

            productCategory = new ProductCategory
            {
                Id   = Guid.NewGuid(),
                Name = "ProductCategory1"
            };

            product1 = new Product
            {
                Id   = Guid.NewGuid(),
                Name = "Product1",
                ProductCategoryId = productCategory.Id,
                Description       = "test"
            };
            product2 = new Product
            {
                Id   = Guid.NewGuid(),
                Name = "Product2",
                ProductCategoryId = productCategory.Id,
                Description       = "test"
            };
            product3 = new Product
            {
                Id   = Guid.NewGuid(),
                Name = "Product3",
                ProductCategoryId = productCategory.Id,
                Description       = "test"
            };
            product4 = new Product
            {
                Id   = Guid.NewGuid(),
                Name = "Product4",
                ProductCategoryId = productCategory.Id,
                Description       = "test"
            };

            fridge = new Fridge
            {
                Id             = Guid.NewGuid(),
                UserId         = user.Id,
                FridgeProducts = new List <FridgeProduct>()
            };

            fridgeProduct1 = new FridgeProduct
            {
                Id        = Guid.NewGuid(),
                FridgeId  = fridge.Id,
                ProductId = product1.Id
            };
            fridgeProduct2 = new FridgeProduct
            {
                Id        = Guid.NewGuid(),
                FridgeId  = fridge.Id,
                ProductId = product2.Id
            };
            fridgeProduct3 = new FridgeProduct
            {
                Id        = Guid.NewGuid(),
                FridgeId  = fridge.Id,
                ProductId = product3.Id
            };
            fridgeProduct4 = new FridgeProduct
            {
                Id        = Guid.NewGuid(),
                FridgeId  = fridge.Id,
                ProductId = product4.Id
            };

            recipe1Product1 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                ProductId = product1.Id,
                RecipeId  = recipe1.Id,
                Recipe    = recipe1,
                Product   = product1
            };
            recipe1Product2 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                ProductId = product2.Id,
                RecipeId  = recipe1.Id,
                Recipe    = recipe1,
                Product   = product2
            };
            recipe1Product3 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                ProductId = product3.Id,
                RecipeId  = recipe1.Id,
                Recipe    = recipe1,
                Product   = product3
            };
            recipe1Product4 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                ProductId = product4.Id,
                RecipeId  = recipe1.Id,
                Recipe    = recipe1,
                Product   = product4
            };

            recipe2Product1 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                ProductId = product1.Id,
                RecipeId  = recipe2.Id,
                Recipe    = recipe2,
                Product   = product1
            };
            recipe2Product2 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                ProductId = product2.Id,
                RecipeId  = recipe2.Id,
                Recipe    = recipe2,
                Product   = product2
            };
            recipe2Product3 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                ProductId = product3.Id,
                RecipeId  = recipe2.Id,
                Recipe    = recipe2,
                Product   = product3
            };
            recipe2Product4 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                ProductId = product4.Id,
                RecipeId  = recipe2.Id,
                Recipe    = recipe2,
                Product   = product4
            };

            recipe3Product1 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                ProductId = product1.Id,
                RecipeId  = recipe3.Id,
                Recipe    = recipe3,
                Product   = product1
            };
            recipe3Product2 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                ProductId = product2.Id,
                RecipeId  = recipe3.Id,
                Recipe    = recipe3,
                Product   = product2
            };
            recipe3Product3 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                ProductId = product3.Id,
                RecipeId  = recipe3.Id,
                Recipe    = recipe3,
                Product   = product3
            };
            recipe3Product4 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                ProductId = product4.Id,
                RecipeId  = recipe3.Id,
                Recipe    = recipe3,
                Product   = product4
            };

            recipe4Product1 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                ProductId = product1.Id,
                RecipeId  = recipe4.Id,
                Recipe    = recipe4,
                Product   = product1
            };
            recipe4Product2 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                ProductId = product2.Id,
                RecipeId  = recipe4.Id,
                Recipe    = recipe4,
                Product   = product2
            };
            recipe4Product3 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                ProductId = product3.Id,
                RecipeId  = recipe4.Id,
                Recipe    = recipe4,
                Product   = product3
            };
            recipe4Product4 = new RecipeProduct
            {
                Id        = Guid.NewGuid(),
                ProductId = product4.Id,
                RecipeId  = recipe4.Id,
                Recipe    = recipe4,
                Product   = product4
            };
        }
Пример #5
0
 public void AddProduct(FridgeProduct fridgeProduct)
 {
     _context.FridgeProducts.Add(fridgeProduct);
 }
Пример #6
0
        public void DeleteProduct(Guid fridgeProductId)
        {
            FridgeProduct delProduct = GetFridgeProductById(fridgeProductId);

            _context.FridgeProducts.Remove(delProduct);
        }