public ActionResult Create()
        {
            var product = new CreateProduct();
            product.CategoryTypes = cat.GetCategoryTypes();

            IEnumerable<AttributeOption> attributeTypes = cat.GetAttributeOptions();
            IEnumerable<Colour> colourOptions = cat.GetColours();

            product.AttributeTypes = attributeTypes;
            product.ColourOptions = colourOptions;

            product.Attributes = new List<CreateProductAttributes>();

            foreach (var att in attributeTypes)
            {
                product.Attributes.Add(new CreateProductAttributes
                {
                    Attribute = att,
                    SelectedAttribute = false
                });
            }

            product.Colours = new List<CreateProductColours>();

            foreach (var colour in colourOptions)
            {
                product.Colours.Add(new CreateProductColours
                {
                    Colour = colour,
                    SelectedColour = false
                });
            }

            return View(product);
        }
        public ActionResult Create(CreateProduct vm)
        {
            vm.NewProduct.Created = DateTime.Now;
            vm.NewProduct.Live = 1;
            vm.CategoryTypes = cat.GetCategoryTypes();
            cat.CreateProduct(vm.NewProduct);

            cat.Save();

            foreach (var attribute in vm.Attributes.Where(e => e.SelectedAttribute))
            {
                ProductAttribute prodat = new ProductAttribute
                {
                    AttributeId = attribute.Attribute.Id,
                    ProductId = vm.NewProduct.Id,
                    Created = DateTime.Now
                };

                cat.AddAttribute(prodat);
            }

            foreach (var colour in vm.Colours.Where(e => e.SelectedColour))
            {
                ProductColour prodcol = new ProductColour
                {
                    ColourId = colour.Colour.Id,
                    ProductId = vm.NewProduct.Id,
                    Created = DateTime.Now
                };

                cat.AddColour(prodcol);
            }
            cat.Save();
            ViewBag.Message = "You have successfully added this product.";

            return View(vm);
        }