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 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()); }
public ActionResult AddToCart(int addid = -1) { if (CommonData()) { return(RedirectToAction("Login", "Account")); } if (addid != -1) { SQLite_Database.GetInstance().AddToShoppingCart(addid, Request.Cookies["LoginEmail"].Value); } return(RedirectToAction("Catalog", "Home")); }
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); }
private void SetUpDatabase(ISettings sett) { //throw new Exception("Test exception"); sett.Restore(); if (sett.Databases.Count == 0) { var sqlite = new SQLite_Database() { Name = "SQLite", ConnectionString = @"Data Source=C:\Work\ToMars\DB\ToMars.db", }; var mssql = new MSSQL_Database() { Name = "MSSQL", ConnectionString = //@"Data Source=AMUR-GO-220\SQLEXPRESS;initial catalog=Bookz;integrated security=True;Connect Timeout=5;" "Data Source=KONAN-PC;initial catalog=Books;integrated security=True;Connect Timeout=30" }; sett.Databases.Add(sqlite); sett.Databases.Add(mssql); sett.SelectedDatabase = sqlite; } }