public ProductColour AddColour(ProductColour colour) { return context.ProductColours.Add(colour); }
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); }