Пример #1
0
        public ActionResult CheckOutBook(int serial)
        {
            // You may have to cast serial to a (uint)
            CheckedOut co = new CheckedOut {
                CardNum = (uint)card, Serial = (uint)serial
            };

            using (Team12LibraryContext db = new Team12LibraryContext()) {
                db.CheckedOut.Add(co);
                try {
                    db.SaveChanges();
                }
                catch (Exception e) {
                    System.Diagnostics.Debug.WriteLine(e.Message);
                    return(Json(new { sucess = false }));
                }
            }

            return(Json(new { success = true }));
        }
Пример #2
0
        public ActionResult ReturnBook(int serial)
        {
            using (Team12LibraryContext db = new Team12LibraryContext()) {
                var query =
                    from co in db.CheckedOut
                    where co.Serial == serial && co.CardNum == card
                    select co;

                foreach (var q in query)
                {
                    db.CheckedOut.Remove(q);
                }
                try {
                    db.SaveChanges();
                }
                catch (Exception e) {
                    System.Diagnostics.Debug.WriteLine(e.Message);
                    return(Json(new { sucess = false }));
                }
            }

            return(Json(new { success = true }));
        }