Пример #1
0
        public void RemoveLineEncodeDecode()
        {
            //SETUP
            var service = new CheckoutCookieService((string)null);

            service.AddLineItem(new OrderLineItem {
                BookId = 1, NumBooks = 4
            });
            service.AddLineItem(new OrderLineItem {
                BookId = 2, NumBooks = 5
            });
            service.AddLineItem(new OrderLineItem {
                BookId = 3, NumBooks = 6
            });

            //ATTEMPT
            service.DeleteLineItem(1);

            //VERIFY
            service.LineItems.Count.ShouldEqual(2);
            service.LineItems[0].BookId.ShouldEqual(1);
            service.LineItems[0].NumBooks.ShouldEqual((short)4);
            service.LineItems[1].BookId.ShouldEqual(3);
            service.LineItems[1].NumBooks.ShouldEqual((short)6);
        }
Пример #2
0
        public IActionResult DeleteLineItem(int lineNum)
        {
            var cookie  = new CheckoutCookie(HttpContext.Request.Cookies, HttpContext.Response.Cookies);
            var service = new CheckoutCookieService(cookie.GetValue());

            service.DeleteLineItem(lineNum);
            cookie.AddOrUpdateCookie(service.EncodeForCookie());
            SetupTraceInfo();
            return(RedirectToAction("Index"));
        }