public ActionResult DeleteConfirmed(string id) { S4452232 s4452232 = db.S4452232.Find(id); db.S4452232.Remove(s4452232); db.SaveChanges(); UpdateDatabase(); SaveBooks(db.S4452232.ToList()); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Index,Name,Author,Year,Price,Stock")] S4452232 s4452232) { if (ModelState.IsValid) { db.Entry(s4452232).State = EntityState.Modified; db.SaveChanges(); SaveBooks(db.S4452232.ToList()); return(RedirectToAction("Index")); } return(View(s4452232)); }
// GET: Book/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } S4452232 s4452232 = db.S4452232.Find(id); if (s4452232 == null) { return(HttpNotFound()); } return(View(s4452232)); }
public ActionResult Search(string attribute, S4452232 book) { var books = from x in db.S4452232 select x; switch (attribute) { case "id": books = books.Where(x => x.ID.Contains(book.ID)); break; case "name": books = books.Where(x => x.Name.Contains(book.Name)); break; case "author": books = books.Where(x => x.Author.Contains(book.Author)); break; case "year": books = books.Where(x => x.Year == book.Year); break; } TempData["books"] = books.ToList(); return(RedirectToAction("/Search")); }
public ActionResult Create([Bind(Include = "ID,Index,Name,Author,Year,Price,Stock")] S4452232 s4452232) { if (ModelState.IsValid) { if (db.S4452232.Any(o => o.ID == s4452232.ID)) { TempData["message"] = "Record already exists."; return(RedirectToAction("/Create")); } db.S4452232.Add(s4452232); db.SaveChanges(); UpdateDatabase(); SaveBooks(db.S4452232.ToList()); return(Redirect("/Book/Create")); } ViewBag.books = db.S4452232.ToList(); return(View(s4452232)); }
public ActionResult DeleteBooks(string attribute, S4452232 book) { switch (attribute) { case "index": if (!db.S4452232.Any(o => o.Index == book.Index)) { TempData["message"] = "Record not found."; return(RedirectToAction("/DeleteBooks")); } db.S4452232.RemoveRange(db.S4452232.Where(x => x.Index == book.Index)); break; case "id": if (!db.S4452232.Any(o => o.ID == book.ID)) { TempData["message"] = "Record not found."; return(RedirectToAction("/DeleteBooks")); } db.S4452232.RemoveRange(db.S4452232.Where(x => x.ID == book.ID)); break; case "year": if (!db.S4452232.Any(o => o.Year == book.Year)) { TempData["message"] = "Record not found."; return(RedirectToAction("/DeleteBooks")); } db.S4452232.RemoveRange(db.S4452232.Where(x => x.Year == book.Year)); break; } db.SaveChanges(); UpdateDatabase(); SaveBooks(db.S4452232.ToList()); return(Redirect("/Book/DeleteBooks")); }
private string BookToString(S4452232 book) { return(book.ID + ',' + book.Name + ',' + book.Author + ',' + book.Year + ",$" + book.Price + ',' + book.Stock); }