public ActionResult UpdateBookStates()
        {
            users = Session["Users"] as Users;
            int id = int.Parse(Request["id"]);
            BorrowBookRecord recordModel = recordDAL.GetEntityModel(id);

            Books book = new Books();

            book.ID     = recordModel.Book_ID.Value;
            book.States = "can borrow book";
            if (booksDAL.UpdateBookStates(book) > 0)
            {
                BorrowBookRecord record = new BorrowBookRecord();
                record.ID             = id;
                record.ReturnBookDate = DateTime.Now;
                record.States         = "return";

                if (recordDAL.UpdateEntityModel(record) > 0)
                {
                    return(Content("ok"));
                }
                else
                {
                    return(Content("no"));
                }
            }
            else
            {
                return(Content("no"));
            }
        }
Esempio n. 2
0
        public ActionResult UpdateBookStates()
        {
            users = Session["Users"] as Users;
            int   bookId = int.Parse(Request["id"]);
            Books book   = new Books();

            book.ID     = bookId;
            book.States = "book out on loan";
            if (booksDAL.UpdateBookStates(book) > 0)
            {
                Books bo = booksDAL.GetEntityModel(bookId);
                BorrowBookRecordDAL recordDAL = new BorrowBookRecordDAL();

                BorrowBookRecord record = new BorrowBookRecord();
                record.User_ID        = users.ID;
                record.User_Name      = users.UserName;
                record.Book_ID        = int.Parse(Request["id"]);
                record.Book_Name      = bo.BookName;
                record.BorrowBookDate = DateTime.Now;
                record.ReturnBookDate = DateTime.Parse("1970-1-1");
                record.States         = "Borrow";
                record.CreateDate     = DateTime.Now;

                if (recordDAL.InsertEntityModel(record) > 0)
                {
                    return(Content("ok"));
                }
                else
                {
                    return(Content("no"));
                }
            }
            else
            {
                return(Content("no"));
            }
        }