public ActionResult AllTitles() { // TODO: Implement using (Team56LibraryContext db = new Team56LibraryContext()) { var query = from t in db.Titles select new { t.Isbn, t.Title, t.Author, Serial = from i in t.Inventory select i.Serial, Name = from compound in ( from p in db.Patrons join c in db.CheckedOut on p.CardNum equals c.CardNum select new { c.Serial, p.Name } ) join item in db.Inventory on compound.Serial equals item.Serial where item.Isbn == t.Isbn select compound.Name }; return(Json(query.ToArray())); } //return Json(null); }
public IActionResult CheckLogin(string name, int cardnum) { bool loginSuccessful = false; // TODO: Fill in. Determine if login is successful or not. using (Team56LibraryContext db = new Team56LibraryContext()) { var query = from t in db.Patrons select new { t.Name, t.CardNum }; foreach (var v in query) { if (v.Name == name && v.CardNum == cardnum) { loginSuccessful = true; } } } if (!loginSuccessful) { return(Json(new { success = false })); } else { user = name; card = cardnum; return(Json(new { success = true })); } }
public ActionResult ListMyBooks() { // TODO: Implement using (Team56LibraryContext db = new Team56LibraryContext()) { var query = from c in db.CheckedOut where c.CardNum == card select new { c.Serial, Title = from compound in ( from i in db.Inventory join t in db.Titles on i.Isbn equals t.Isbn select new { t.Title, i.Serial } ) join e in db.CheckedOut on compound.Serial equals e.Serial where e.CardNum == card && e.Serial == c.Serial select compound.Title }; return(Json(query.ToArray())); } }
public ActionResult CheckOutBook(int serial) { // You may have to cast serial to a (uint) using (Team56LibraryContext db = new Team56LibraryContext()) { CheckedOut book = new CheckedOut(); book.CardNum = (uint)card; book.Serial = (uint)serial; db.CheckedOut.Add(book); db.SaveChanges(); // } return(Json(new { success = true })); }