public ActionResult Create(Manufacturer manufacturer) { if (ModelState.IsValid) { db.Manufacturers.Add(manufacturer); db.SaveChanges(); return RedirectToAction("Index"); } return View(manufacturer); }
public ActionResult Edit(Manufacturer manufacturer) { if (ModelState.IsValid) { db.Entry(manufacturer).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(manufacturer); }
public void populateManufacturers() { CCINVEntities _db = new CCINVEntities(); Manufacturer thisManufacturer = new Manufacturer(); List<string> Names = new List<string>(); Names.Add("America's Cups"); Names.Add("Charlie's Cup Emporium"); Names.Add("Greenville Cups Inc"); Names.Add("Tervis"); Names.Add("Paper Products Cupers"); Names.Add("Charleston's Cup Company"); Names.Add("New York's Cups Inc"); Names.Add("Chinese Can Cup"); Names.Add("English Tea Cozies"); foreach (string name in Names) { thisManufacturer.Name = name; _db.Manufacturers.Add(thisManufacturer); } try { _db.SaveChanges(); } catch (Exception e) { //Do nothing yet } }