public ActionResult SpecEdit(tblProductSpec tblProductSpec) { if (ModelState.IsValid) { db.Entry(tblProductSpec).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("ProductEdit", null, new { id = tblProductSpec.ProductId }); } return View(tblProductSpec); }
public ActionResult ProductAddDo(int cat) { //Get a list of specIds related to the category they would like to add a product to var speclist = (from c in db.tblCategorySpecificSpecs where c.CategoryId == cat select c).ToList(); //Add the product record tblProduct prod = new tblProduct(); prod.CategoryId = cat; prod.Active = false; db.tblProducts.Add(prod); //Create a record for each specid foreach (var item in speclist) { tblProductSpec prodSpec = new tblProductSpec(); prodSpec.CatSpecId = item.CSpecId; prodSpec.ProductId = prod.ProductId; prodSpec.SpecValue1 = "1"; prodSpec.SpecValue2 = "2"; db.tblProductSpecs.Add(prodSpec); } //Save db.SaveChanges(); return RedirectToAction("ProductEdit", null, new { id = prod.ProductId }); //return View("ProductEdit", prod.ProductId); }