protected void AddToCart_ItemCommand(object sender, ListViewCommandEventArgs e) { int stockitemid = int.Parse(e.CommandArgument.ToString()); ApplicationUserManager userManager = new ApplicationUserManager(new UserStore <ApplicationUser>(new ApplicationDbContext())); string userName = Context.User.Identity.GetUserName(); int employeeid = 0; if (!string.IsNullOrEmpty(userName)) { employeeid = userManager.Get_CurrentEmployeeIDFromUserName(userName); } int qty = 0; int.TryParse((e.Item.FindControl("QuantitySelected") as TextBox).Text, out qty); if (qty < 1) { MessageUserControl.ShowInfo("Could not add item to shopping cart. Quantity must be greater than zero."); } else { MessageUserControl.TryRun(() => { ShoppingCartController sysmgr = new ShoppingCartController(); sysmgr.Add_ProductToShoppingCart(employeeid, stockitemid, qty); }, "Product Added", "The product has been added to your cart."); } }