Esempio n. 1
0
        public static Dictionary <BookStatModel, int> GetTopSellingBooks(int count)
        {
            Dictionary <BookStatModel, int> dict = new Dictionary <BookStatModel, int>();
            var reader = BookStatDAL.SelectTopSellingBooksOnSale(count);

            while (reader.Read())
            {
                dict.Add(BookStatBLL.GetBookByID(reader.GetInt32(0)), reader.GetInt32(1));
            }
            return(dict);
        }
Esempio n. 2
0
        public static CartModel GetUserCart(int userid)
        {
            CartModel cart = new CartModel();

            cart.user = UserInfoBLL.GetUserInfoByID(userid);
            var reader = CartDAL.SelectBooksInCart(userid);

            while (reader.Read())
            {
                BookOrderModel book = new BookOrderModel();
                book.book     = BookStatBLL.GetBookByID(reader.GetInt32(0));
                book.enabled  = 1;
                book.quantity = reader.GetInt32(1);
                cart.book.Add(book);
            }
            reader.Close();
            return(cart);
        }
Esempio n. 3
0
        public static OrderModel GetOrderByID(int id)
        {
            OrderModel order  = new OrderModel();
            var        reader = OrderDAL.SelectOrderByID(id);

            if (reader == null)
            {
                return(new OrderModel());
            }
            reader.Read();
            order.id = reader.GetInt32(0);
            int userid = reader.GetInt32(1);

            order.dateTime   = reader.GetDateTime(2);
            order.totalPrice = reader.GetDouble(3);
            order.comment    = reader.GetString(4);
            order.status     = (OrderStatus)reader.GetInt32(5);
            int addressid = reader.GetInt32(6);

            order.user    = UserInfoBLL.GetUserInfoByID(userid);
            order.address = AddressBLL.GetAddressByID(addressid);
            order.books   = new List <BookOrderModel>();
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            reader = OrderDAL.SelectOrderBooksByID(id);
            while (reader.Read())
            {
                BookOrderModel bookOrder = new BookOrderModel();
                bookOrder.book     = BookStatBLL.GetBookByID(reader.GetInt32(0));
                bookOrder.quantity = reader.GetInt32(2);
                bookOrder.price    = reader.GetDouble(3);
                order.books.Add(bookOrder);
            }
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            return(order);
        }