Beispiel #1
0
        //______________________________________________________________________________________

        /// <summary>
        /// Product/RemoveFromFrontCart/5
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>

        public ActionResult RemoveFromFrontCart(int id)
        {
            try
            {
                if (Session["usertype"] != null)
                {
                    string LoggedInUser = @User.Identity.Name;
                    ShoppingCartImplementation.RemoveFromCart(id, LoggedInUser);
                    return(RedirectToAction("Index", "Product" /*, new { id = LoggedInUser }*/));
                }
                else
                {
                    return(RedirectToAction("Index", "Product"));
                }
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, "UI Policy");
                if (rethrow)
                {
                    throw;
                }
                return(RedirectToAction("Index", "Product"));
            }
        }
Beispiel #2
0
        public void RemoveFromCartTest()
        {
            string UserId = "ashaka";
            List <AddToCartModel> list = new List <AddToCartModel>();

            list = ShoppingCartImplementation.GetFromCart(UserId);
            int    x  = list.Count;
            int    id = 5;
            string actual;

            actual = ShoppingCartImplementation.RemoveFromCart(id, UserId);
            List <AddToCartModel> list1 = new List <AddToCartModel>();

            list1 = ShoppingCartImplementation.GetFromCart(UserId);
            int y = list1.Count;

            Assert.AreEqual(y + 1, x);
        }
Beispiel #3
0
        //______________________________________________________________________________________

        /// <summary>
        /// Product/RemoveFromCart/5
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>

        public ActionResult RemoveFromCart(int id)
        {
            try
            {
                if (Session["usertype"] != null)
                {
                    string LoggedInUser = @User.Identity.Name;
                    ShoppingCartImplementation.RemoveFromCart(id, LoggedInUser);
                    return(RedirectToAction("Cart", "Product" /*, new { id = LoggedInUser }*/));
                }
                else
                {
                    return(RedirectToAction("Index", "Product"));
                }
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Product"));
            }
        }