// GET: CheckOutBooks/Create public ActionResult Create() { // Defining Values to pass into ViewBag below selectListStudents and Books var students = db.Students.Where(s => s.StudentsID == s.StudentsID).ToList(); IEnumerable <SelectListItem> selectListStudents = from s in students select new SelectListItem { Value = s.StudentsID.ToString(), Text = s.StudentName + ", UVUID: " + s.UVUID + " " }; var books = db.Books.Where(s => s.BooksID == s.BooksID).ToList(); IEnumerable <SelectListItem> selectListBooks = from s in books select new SelectListItem { Value = s.BooksID.ToString(), Text = s.Title + ", ISBN: " + s.ISBN + ", Number: " + s.Number + ", Class Room: " + s.ClassRoom + " " }; ViewBag.BooksID = new SelectList(selectListBooks, "Value", "Text"); ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "DepName"); ViewBag.StudentsID = new SelectList(selectListStudents, "Value", "Text"); CheckOutBook model = new CheckOutBook(); model.CheckedOutDate = DateTime.Now; model.DueDate = DateTime.Now.AddDays(7); return(View(model)); }
public ActionResult DeleteConfirmed(int id) { CheckOutBook checkOutBook = db.CheckOutBooks.Find(id); db.CheckOutBooks.Remove(checkOutBook); db.SaveChanges(); return(RedirectToAction("Index")); }
public static void PrintMainMenu() { Console.WriteLine(@"Welcome to the Huntington Library System Please select an option: 1. Check out a book 2. Return a book 3. View patrons with overdue books 4. Create a new patron 5. Check patron status 6. Check book status 7. Delete a patron 8. Edit a patron's information 9. View reports "); string input = Console.ReadLine(); switch (Int32.Parse(input)) { case 1: CheckOutBook.CollectInput(); break; case 2: break; case 3: break; case 4: break; case 5: break; case 6: CheckBookStatus.CollectInput(); break; case 7: break; case 8: break; case 9: break; default: Console.WriteLine("Please select a valid option."); PrintMainMenu(); break; } ; }
// GET: CheckOutBooks/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CheckOutBook checkOutBook = db.CheckOutBooks.Find(id); if (checkOutBook == null) { return(HttpNotFound()); } return(View(checkOutBook)); }
public ActionResult Edit([Bind(Include = "CheckOutBookID,StudentsID,BooksID,DepartmentID,DueDate,ReturnedBook,ReturnedDate,CheckedOutDate")] CheckOutBook checkOutBook) { if (checkOutBook.ReturnedBook) { DateTime CurrentDate = DateTime.Now; checkOutBook.ReturnedDate = CurrentDate; db.Entry(checkOutBook).State = EntityState.Modified; } if (ModelState.IsValid) { db.Entry(checkOutBook).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BooksID = new SelectList(db.Books, "BooksID", "Title", checkOutBook.BooksID); ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "DepName", checkOutBook.DepartmentID); ViewBag.StudentsID = new SelectList(db.Students, "StudentsID", "StudentName", checkOutBook.StudentsID); return(View(checkOutBook)); }
public ActionResult Create([Bind(Include = "CheckOutBookID,StudentsID,BooksID,DepartmentID,DueDate,ReturnedBook,ReturnedDate,CheckedOutDate")] CheckOutBook checkOutBook) { if (ModelState.IsValid) { try { db.CheckOutBooks.Add(checkOutBook); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(Content("check out request was invalid go back and try again")); } } ViewBag.BooksID = new SelectList(db.Books, "BooksID", "Title", checkOutBook.BooksID); ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "DepName", checkOutBook.DepartmentID); ViewBag.StudentsID = new SelectList(db.Students, "StudentsID", "StudentName", checkOutBook.StudentsID); return(View(checkOutBook)); }
// GET: CheckOutBooks/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CheckOutBook checkOutBook = db.CheckOutBooks.Find(id); if (checkOutBook == null) { return(HttpNotFound()); } // Defining Values to pass into ViewBag below selectListStudents and Books var students = db.Students.Where(s => s.StudentsID == s.StudentsID).ToList(); IEnumerable <SelectListItem> selectListStudents = from s in students select new SelectListItem { Value = s.StudentsID.ToString(), Text = s.StudentName + ", UVUID: " + s.UVUID + " " }; var books = db.Books.Where(s => s.BooksID == s.BooksID).ToList(); IEnumerable <SelectListItem> selectListBooks = from s in books select new SelectListItem { Value = s.BooksID.ToString(), Text = s.Title + ", ISBN: " + s.ISBN + ", Number: " + s.Number + ", Class Room: " + s.ClassRoom + " " }; ViewBag.BooksID = new SelectList(selectListBooks, "Value", "Text", checkOutBook.BooksID); ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "DepName", checkOutBook.DepartmentID); ViewBag.StudentsID = new SelectList(selectListStudents, "Value", "Text", checkOutBook.StudentsID); return(View(checkOutBook)); }