public IActionResult AddProduct(newAssociationFromCategory returnAsso)
        {
            if (!ModelState.IsValid)
            {
                Category ThisCategory = dbContext.Categories
                                        .Include(a => a.Associations)
                                        .ThenInclude(thisassociation => thisassociation.Product)
                                        .FirstOrDefault(category => category.CategorytId == returnAsso.CategorytId);


                List <Product> OwnedProducts = ThisCategory.Associations
                                               .Select(a => a.Product).ToList();
                List <Product> ListProducts = dbContext.Products
                                              .Where(pro => !pro.Associations.Any(c => c.CategorytId == returnAsso.CategorytId))
                                              .ToList();

                newAssociationFromCategory updateCategory = new newAssociationFromCategory();
                updateCategory.CategorytId   = returnAsso.CategorytId;
                updateCategory.ThisCategory  = ThisCategory;
                updateCategory.ListProducts  = ListProducts;
                updateCategory.OwnedProducts = OwnedProducts;
                // Console.WriteLine("updateProduct.ProductId", updateCategory.ProductId);
                // Console.WriteLine()
                return(View("ShowCategory", updateCategory));
            }

            else
            {
                Association newAssosi = new Association();
                newAssosi.CategorytId = returnAsso.CategorytId;
                newAssosi.ProductId   = returnAsso.ProductId;

                dbContext.Associations.Add(newAssosi);
                dbContext.SaveChanges();
                return(Redirect("/categories/" + returnAsso.CategorytId));
            }
        }
        public IActionResult ShowCategory(int categoryId)
        {
            Category ThisCategory = dbContext.Categories
                                    .Include(a => a.Associations)
                                    .ThenInclude(thisassociation => thisassociation.Product)
                                    .FirstOrDefault(category => category.CategorytId == categoryId);


            List <Product> OwnedProducts = ThisCategory.Associations
                                           .Select(a => a.Product).ToList();
            List <Product> ListProducts = dbContext.Products
                                          .Where(pro => !pro.Associations.Any(c => c.CategorytId == categoryId))
                                          .ToList();

            newAssociationFromCategory updateCategory = new newAssociationFromCategory();

            updateCategory.CategorytId   = categoryId;
            updateCategory.ThisCategory  = ThisCategory;
            updateCategory.ListProducts  = ListProducts;
            updateCategory.OwnedProducts = OwnedProducts;
            // Console.WriteLine("updateProduct.ProductId", updateCategory.ProductId);
            // Console.WriteLine()
            return(View(updateCategory));
        }