public ActionResult BuyingBooksCourseFiltered(int courseFilter) { var book = new ENNewBook(); var books = book.ReadAll(); books = books.Where(b => b.Subject.Course.Id == courseFilter).ToList(); return(View("BuyingBooks", books)); }
public ActionResult RemoveFromCart(int id) { var book = new ENNewBook(); var nbook = book.Read(id); ShoppingCart.Instance.RemoveItem(nbook); return(RedirectToAction("Cart")); }
public void NewBookVerifyingPrice() { var newBook = new ENNewBook(); newBook = newBook.Read(1); var price = newBook.Price; //used to fail casting }
/** * RemoveItem() - Removes an item from the shopping cart */ public void RemoveItem(ENNewBook book) { CartItem removedItem = new CartItem(book); foreach (var item in Items) { if (item.Book.Id == book.Id) { Items.Remove(item); break; } } }
public ActionResult BuyingBooks() { var book = new ENNewBook(); var books = book.ReadAll(); /* * var book = new Book("012345", "Mi bonico libro daprender", 99.01f, "/Scripts/widgets/jqwidgets/images/books/Carrie.jpg"); * var book1 = new Book("012346", "Sueños rallantes", 34.29f, "/Scripts/widgets/jqwidgets/images/inception.jpg"); * var book2 = new Book("012347", "El oso peleon", 1.10f, "/Scripts/widgets/jqwidgets/images/kungfupanda.png"); * var book3 = new Book("012348", "Hostias como panes", 22.99f, "/Scripts/widgets/jqwidgets/images/knockout.png"); * var books = new List<Book>(); * books.Add(book); * books.Add(book1); * books.Add(book2); * books.Add(book3);*/ return(View("BuyingBooks", books)); }
/** * AddItem() - Adds an item to the shopping */ public void AddItem(ENNewBook book) { // Create a new item to add to the cart ENNewBook b = new ENNewBook(book.Id); CartItem newItem = new CartItem(b); // If this item already exists in our list of items, increase the quantity // Otherwise, add the new item to the list foreach (CartItem item in Items) { if (item.Book.Id == book.Id) { item.Quantity++; return; } } newItem.Quantity = 1; Items.Add(newItem); }
public CartItem(ENNewBook book) { this.Book = book; this.Id = book.Id; this.Quantity = 1; }