예제 #1
0
        public void getNonExistent()
        {
            RestAccess db = RestAccess.GetInstance();
            Book       b  = db.GetBook(999999999);

            Assert.AreEqual(b, null);
        }
예제 #2
0
        public ActionResult Catalog(String showid = null)
        {
            CommonData();
            RestAccess           ra       = RestAccess.GetInstance();
            SQLite_Database      sd       = SQLite_Database.GetInstance();
            List <InventoryBook> IBooks   = sd.GetInventoryBooks();
            List <String>        showline = null;
            int sbid = -99;

            ViewData["showmodal"] = false;
            if (showid != null)
            {
                sbid = Convert.ToInt32(showid);
                ViewData["showmodal"] = true;
            }

            List <List <String> > bookInfo = new List <List <String> >();

            for (int i = 0; i < IBooks.Count; i++)
            {
                //System.Diagnostics.Debug.Print(IBooks[i].GetBook().ToString());
                Book b = ra.GetBook(IBooks[i].GetBook());
                bookInfo.Add(new List <String>());
                bookInfo[i].Add(b.Name);
                bookInfo[i].Add(b.Author);
                bookInfo[i].Add(b.desc);
                bookInfo[i].Add("$" + b.Price.ToString());
                bookInfo[i].Add(b.BookId.ToString());
                bookInfo[i].Add(IBooks[i].GetStock().ToString());
                bookInfo[i].Add(IBooks[i].IsEnabled.ToString());
                if (b.BookId == sbid)
                {
                    showline            = bookInfo[i];
                    ViewData["reviews"] = IBooks[i].reviews;
                }
            }
            ViewData["bookInfo"] = bookInfo;
            ViewData["showline"] = null;
            if (showid != null)
            {
                if (showline == null)
                {
                    ViewData["showline"] = new List <String>()
                    {
                        "dummy", "dummy", "dummy", "dummy", "dummy", "dummy"
                    };
                    ViewData["reviews"] = new List <Review>();
                }
                else
                {
                    ViewData["showline"] = showline;
                }
            }

            ViewData["convert"] = RestAccess.GetInstance().CurrRates;

            return(View());
        }
예제 #3
0
        public static bool PurchaseShoppingCart(List <ShoppingCartBook> sBooks)
        {
            SQLite_Database localAccess  = SQLite_Database.GetInstance();
            RestAccess      remoteAccess = RestAccess.GetInstance();

            //Loop through each book and create a transaction
            foreach (var sBook in sBooks)
            {
                var price = remoteAccess.GetBook(sBook.bookID).Price; //Get book's price
                localAccess.CreateTransaction(sBook.UserID, sBook.bookID, price);
            }

            return(false);
        }
예제 #4
0
        public void UpdateBook()
        {
            RestAccess  db    = RestAccess.GetInstance();
            List <Book> list  = db.GetBooks();
            int         id    = list.First().BookId;
            String      auth  = list.First().Author;
            float       price = list.First().Price;
            String      name  = list.First().Name;
            String      desc  = list.First().desc;

            db.UpdateBook(id, "name", 11037, "44", "desc");

            Book book = db.GetBook(id);

            db.UpdateBook(id, auth, price, name, desc);
            Assert.AreEqual(book.Author, "name");
        }
예제 #5
0
        public ActionResult ShoppingCart()
        {
            if (CommonData())
            {
                return(RedirectToAction("Login", "Account"));
            }
            ViewData["lgnusr"] = getCurrentUser();
            RestAccess           ra     = RestAccess.GetInstance();
            SQLite_Database      sd     = SQLite_Database.GetInstance();
            List <InventoryBook> IBooks = sd.GetInventoryBooks();
            List <Book>          books  = new List <Book>();

            for (int i = 0; i < IBooks.Count; i++)
            {
                books.Add(ra.GetBook(IBooks[i].GetBook()));
            }

            List <List <String> > bookInfo = new List <List <String> >();

            for (int i = 0; i < books.Count; i++)
            {
                bookInfo.Add(new List <String>());
                bookInfo[i].Add(books[i].Name);
                bookInfo[i].Add(books[i].Author);
                bookInfo[i].Add(books[i].desc);
                bookInfo[i].Add("$" + books[i].Price.ToString());
                bookInfo[i].Add(books[i].BookId.ToString());
                bookInfo[i].Add(IBooks[i].GetStock().ToString());
            }
            ViewData["bookInfo"] = bookInfo;
            for (int i = 0; i < IBooks.Count; i++)
            {
                ViewData[IBooks[i].GetBook() + "reviews"] = IBooks[i].reviews;
            }
            return(View());
        }