public ActionResult DeleteConfirmed(int id) { ListOfType listOfType = db.ListOfTypes.Find(id); listOfType.Hide = true; db.ListOfTypes.Remove(listOfType); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Type,Hide")] ListOfType listOfType) { if (ModelState.IsValid) { db.Entry(listOfType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(listOfType)); }
// GET: ListOfTypes/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ListOfType listOfType = db.ListOfTypes.Find(id); if (listOfType == null) { return(HttpNotFound()); } return(View(listOfType)); }
public ActionResult Create([Bind(Include = "ID,Type")] ListOfType listOfType) { if (ModelState.IsValid) { foreach (var type in listOfType.Type.Split(',')) { bool FoundType = db.ListOfTypes.Where(m => m.Type.Contains(listOfType.Type)).Count() > 0; if (!FoundType) { db.ListOfTypes.Add(new ListOfType() { Type = type }); db.SaveChanges(); } } return(RedirectToAction("Index")); } return(View(listOfType)); }