Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // set title for page
            Page.Title = "Book Details - BookShare";

            if (Request.QueryString["id"] == null || Session["currentUser"] == null)
            {
                Server.Transfer("ErrorPage.aspx");
            }
            else
            {
                user   = (User)Session["currentUser"];
                idBook = int.Parse(Request.QueryString["id"]);
                BookDAO bookDAO = new BookDAO();
                //Get book by id
                book = bookDAO.GetById(idBook);

                //Get all lenders for this book
                TradingDAO tradingDAO    = new TradingDAO();
                int        tradingStatus = 0; //Get all available trading
                tradings = tradingDAO.getAllTradingOfOneBookPaging(idBook, user.Id, tradingStatus);

                //Get all lenders according to tradings
                lenders = new List <User>();
                UserDAO userDAO = new UserDAO();
                foreach (Trading t in tradings)
                {
                    User u = userDAO.GetById(t.LenderID);
                    lenders.Add(u);
                }

                //Get all traded images
                foreach (Trading t in tradings)
                {
                    tradingDAO = new TradingDAO();
                    List <string> tradedImages = new List <string>();
                    tradedImages   = tradingDAO.getAllTradedImages(t.Id);
                    t.TradedImages = tradedImages;
                }
            }
        }