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()); } }
public void Configuration(IAppBuilder app) { ConfigureAuth(app); RestAccess ra = RestAccess.GetInstance(); Database_Test.SQLite_Database db = Database_Test.SQLite_Database.GetInstance(); }
public void getNonExistent() { RestAccess db = RestAccess.GetInstance(); Book b = db.GetBook(999999999); Assert.AreEqual(b, null); }
public void updateNonExistent() { RestAccess db = RestAccess.GetInstance(); Boolean b = db.UpdateBook(999999999, "", 3, "", ""); Assert.AreEqual(b, false); }
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()); }
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")); }
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")); }
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); }
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); }
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"); }
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"); }