public ActionResult Edit(long id) { CodeFirstDatabaseEntities db = new CodeFirstDatabaseEntities(); Brand2 thisbrand = db.Brands.Where(br => br.BrandID == id).FirstOrDefault(); return(View(thisbrand)); }
public ActionResult Delete(long id, Brand2 br) { CodeFirstDatabaseEntities db = new CodeFirstDatabaseEntities(); Brand2 toDeleteBrand2 = db.Brands.Where(t2 => t2.BrandID == id).FirstOrDefault(); db.Brands.Remove(toDeleteBrand2); db.SaveChanges(); return(RedirectToAction("Index", "Brands")); }
public ActionResult Edit(Brand2 br) { CodeFirstDatabaseEntities db = new CodeFirstDatabaseEntities(); if (ModelState.IsValid) { Brand2 thisBrand = db.Brands.Where(a => a.BrandID == br.BrandID).FirstOrDefault(); thisBrand.BrandName = br.BrandName; db.SaveChanges(); return(RedirectToAction("Index", "Brands")); } return(View(br)); }
public ActionResult Create(Brand2 br) { CodeFirstDatabaseEntities db = new CodeFirstDatabaseEntities(); if (ModelState.IsValid) { db.Brands.Add(br); db.SaveChanges(); return(RedirectToAction("Index")); } else { return(View(br)); } }