예제 #1
0
        public ActionResult Reciepts()
        {
            {
                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());
                }
                ViewData["bookInfo"] = bookInfo;
                return(View());
            }
        }
예제 #2
0
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);
            RestAccess ra = RestAccess.GetInstance();

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

            Assert.AreEqual(b, null);
        }
예제 #4
0
        public void updateNonExistent()
        {
            RestAccess db = RestAccess.GetInstance();
            Boolean    b  = db.UpdateBook(999999999, "", 3, "", "");

            Assert.AreEqual(b, false);
        }
예제 #5
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());
        }
예제 #6
0
 private User getCurrentUser()
 {
     if (Request.Cookies["LoginEmail"] != null)
     {
         String value = Request.Cookies["LoginEmail"].Value;
         return(RestAccess.GetInstance().GetUserByEmail(value));
     }
     return(new User(-99, "*****@*****.**", "Unknown", "User", "dummy"));
 }
예제 #7
0
 private User getCurrentUser()
 {
     if (Request.Cookies["LoginEmail"] != null)
     {
         String value = Request.Cookies["LoginEmail"].Value;
         ViewData["LoginEmail"] = value;
         return(RestAccess.GetInstance().GetUserByEmail(value));
     }
     return(new User(-99, "dummy", "Please", "Login", "dummy"));
 }
예제 #8
0
        public Boolean AddToShoppingCart(int bookid, string email)
        {
            String        command = "insert into ShoppingCartBook(BookID, BookStoreID, Date, UserID) values (@BOOKID, 1, @DATE, @USERID)";
            SQLiteCommand insert  = new SQLiteCommand(command, dbConnection);

            insert.Parameters.Add(new SQLiteParameter("@BOOKID", bookid));
            insert.Parameters.Add(new SQLiteParameter("@DATE", DateTimeSQLite(DateTime.Now)));
            insert.Parameters.Add(new SQLiteParameter("@USERID", RestAccess.GetInstance().GetUserByEmail(email).GetUid()));


            insert.ExecuteNonQuery();
            return(true);
        }
예제 #9
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);
        }
예제 #10
0
        public void CreateBook()
        {
            RestAccess db = RestAccess.GetInstance();

            db.CreateBook("name", 999, "name", "desc");
            System.Diagnostics.Debug.WriteLine("after creation");
            List <Book> list = db.GetBooks();

            System.Diagnostics.Debug.WriteLine("AFTER GETBOOKS");
            Book book = list.Last();

            System.Diagnostics.Debug.WriteLine("GOT TO DELETE");
            db.DeleteLastBook();

            Assert.AreEqual(book.Author, "name");
        }
예제 #11
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");
        }