Ejemplo n.º 1
0
        //查看本次借阅的图书
        public ActionResult Completed(Shelf shelf, Reader reader, string returnUrl, int[] bookid)
        {
            List <Book> books = new List <Book>();

            if (reader.Id == 0)
            {
                return(RedirectToAction("Login", "Reader"));
            }
            else if (bookid.Length == 0)
            {
                return(View("Index", new { returnUrl }));
            }
            else
            {
                for (var i = 0; i < bookid.Length; i++)
                {
                    Book book = repository.FindBookById(bookid[i]);
                    books.Add(book);
                }
                //注意一定要先生成一条新的订单,再生成一条新的借阅记录(借阅记录具有外键FineId)
                borrowProcessor.ProcessFine(books);
                borrowProcessor.ProcessBorrow(books, reader);
                Session["Shelf"]           = null;
                ViewBag.readerName         = reader.Name;
                ViewBag.BorrowTime         = DateTime.Now;
                ViewBag.DateShouldBeReturn = DateTime.Now.AddMonths(1);
                ViewBag.ReturnUrl          = returnUrl;
                return(View(books));
            }
        }