public ActionResult AllTitles() { using (Team69LibraryContext db = new Team69LibraryContext()) { var query = from title in db.Titles join inven in db.Inventory on title.Isbn equals inven.Isbn into tempTable from tTable in tempTable.DefaultIfEmpty() //from anotherTitle in db.Titles //join inventory in db.Inventory on anotherTitle.Isbn equals inventory.Isbn join checkedO in db.CheckedOut on tTable.Serial equals checkedO.Serial into tempTable2 from tTable2 in tempTable2.DefaultIfEmpty() join patr in db.Patrons on tTable2.CardNum equals patr.CardNum into tempTable3 from tTable3 in tempTable3.DefaultIfEmpty() select new { title.Title, title.Author, title.Isbn, Serial = (tTable == null ? (uint?)null : tTable.Serial), name = (tTable2 == null ? "" : tTable3.Name) }; String a = ""; return(Json(query.ToArray())); } }
public IActionResult CheckLogin(string name, int cardnum) { // TODO: Fill in. Determine if login is successful or not. bool loginSuccessful = false; using (Team69LibraryContext db = new Team69LibraryContext()) { var query = from p in db.Patrons select p; String userName = name; userName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(userName.ToLower()); foreach (var v in query) { if (userName.Equals(v.Name) && cardnum == v.CardNum) { loginSuccessful = true; } //System.Diagnostics.Debug.WriteLine(v.CardNum); //System.Diagnostics.Debug.WriteLine(v.Name); } } if (!loginSuccessful) { return(Json(new { success = false })); } else { user = name; card = cardnum; return(Json(new { success = true })); } }
public ActionResult ReturnBook(int serial) { // You may have to cast serial to a (uint) using (Team69LibraryContext db = new Team69LibraryContext()) { CheckedOut book = new CheckedOut { CardNum = (uint)card, Serial = (uint)serial }; db.CheckedOut.Remove(book); db.SaveChanges(); } return(Json(new { success = true })); }
public ActionResult ListMyBooks() { using (Team69LibraryContext db = new Team69LibraryContext()) { var query = (from patron in db.Patrons join checkedOut in db.CheckedOut on patron.CardNum equals checkedOut.CardNum join inventory in db.Inventory on checkedOut.Serial equals inventory.Serial join title in db.Titles on inventory.Isbn equals title.Isbn where patron.Name == user select new { title.Title, title.Author, checkedOut.Serial, }).ToList(); return(Json(query)); } //return Json(null); }