public void AddToCart_Test() { var pr = pc.GetProductByID(3); cm.AddToCart(1, pr); Assert.IsNotNull(cm); }
public ActionResult AddToCart(int id) { _cartManager.AddToCart(id); return(RedirectToAction("Index")); }
public ActionResult AddToCart(string id) { cartMan.AddToCart(Int32.Parse(id)); return(RedirectToAction("Index")); }
protected void AddCartButton_Click(object sender, EventArgs e) { CartManager cartManager = new CartManager(); if (Session["name"].ToString() == null || Session["name"].ToString() == "") { Response.Redirect("Lgoin.aspx"); } string cartId = Session["CartId"].ToString(); if (cartId != null && cartId != "") { cartManager.AddToCart(Amount.Text, productId, Session["name"].ToString(), cartId); Response.Redirect("ShoppingCart.aspx?CartId=" + cartId); } else { cartManager.AddToCart(Amount.Text, productId, Session["name"].ToString(), ""); Response.Redirect("~/"); } }
public void AddToCart(int product) { var customerId = HttpContext.Session.GetInt32("customer"); if (customerId != null) { CartManager cartManager = CustomerManager.GetCustomerCart(dbContext, (int)customerId); if (cartManager != null) { cartManager.AddToCart(product, 1); } } HttpContext.Response.Redirect("/Cart/Index"); }
public ActionResult AddToCart(int product_id) { cartManager.AddToCart(product_id); return(RedirectToAction("Index")); }
public ActionResult AddToCart(int id) { cartManager.AddToCart(id); return(RedirectToAction("Index")); //w nawiasie string z nazwą akcji }
public string AddToCart(Entities.Models.Cart cart) { return(carts.AddToCart(cart)); }
static void Main(string[] args) { var inventoryManager = new InventoryManager(); var cartManager = new CartManager(); var keyPressed = default(ConsoleKeyInfo); do { WriteLine("1 - List Products"); WriteLine("2 - Display Cart Items"); WriteLine("3 - Add Item to Cart"); WriteLine("4 - Place Order"); WriteLine("Press Command.. Q to exit"); keyPressed = ReadKey(); switch (keyPressed.Key) { case ConsoleKey.D1: var products = inventoryManager.GetProducts(); if (products.Count <= 0) { WriteLine("No record available"); } else { WriteLine(); foreach (var product in products) { WriteLine($"{product.Name} {product.Price}"); } } break; case ConsoleKey.D2: WriteLine("\nInput UserId"); int userId; var inputFlag = int.TryParse(ReadLine(), out userId); if (inputFlag == false) { WriteLine("Input is not an integer, Pls Provide an integer value"); } else { var cart = cartManager.GetCart(userId); if (cart != null) { WriteLine($"cart for userId: {userId}"); foreach (var item in cart.Items) { WriteLine($"{item.Product.Name} - {item.Product.Price} - {item.Quantity}"); } } else { WriteLine($"No cart item for user: {userId}, Pls add item to cart"); } } break; case ConsoleKey.D3: WriteLine("\nInput the UserId"); inputFlag = int.TryParse(ReadLine(), out userId); if (inputFlag == false) { WriteLine("Input is not an integer, Pls Provide an integer value"); } else { WriteLine("Input ProductId"); int productId; inputFlag = int.TryParse(ReadLine(), out productId); if (inputFlag == false) { WriteLine("Input is not an integer, Pls Provide an integer value"); } else { var cartModel = new CartModel(); cartModel.UserId = userId; cartModel.Items.Add(new ItemModel { ProductId = productId }); if (cartManager.AddToCart(cartModel)) { WriteLine("Item added successfully"); } else { WriteLine("Failed to add item to cart"); } } } break; } WriteLine(Environment.NewLine); } while (keyPressed.Key != ConsoleKey.Q); }
void AddToCart() { manager.AddToCart(product.product_id); }
public ActionResult AddToCart(int id) { cartManager.AddToCart(id); return(RedirectToAction(nameof(Index))); }
public ActionResult AddToCart(int bookId) { cartMenager.AddToCart(bookId); return(RedirectToAction("Index")); }