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); }
public IActionResult AddToCart(OrderLineItem itemToBuy) { var cookie = new CheckoutCookie(HttpContext.Request.Cookies, HttpContext.Response.Cookies); var service = new CheckoutCookieService(cookie.GetValue()); service.AddLineItem(itemToBuy); cookie.AddOrUpdateCookie(service.EncodeForCookie()); return(RedirectToAction("Index")); }
public RedirectToActionResult ChooseItems(OrderLineItemDto modifiedDto) { var listService = new ListItemServices(_context); var cookie = new CheckoutCookie(HttpContext.Request.Cookies, HttpContext.Response.Cookies); var service = new CheckoutCookieService(cookie.GetValue()); service.AddLineItem(modifiedDto.RetriveOrderLineItemDto()); cookie.AddOrUpdateCookie(service.EncodeForCookie()); return(RedirectToAction("Index")); }
public IActionResult Buy(OrderItem itemToBuy) { var cookie = new CheckoutCookie(HttpContext.Request.Cookies, HttpContext.Response.Cookies); //create a new cookie var service = new CheckoutCookieService(cookie.GetValue()); //create a new List of OrderLineItem and add the items in the existing cookie to it service.AddLineItem(itemToBuy); //add itemto Buy to the List of OrderLineitems cookie.AddOrUpdateCookie(service.EncodeForCookie()); //update cookie return(RedirectToAction("Index")); }
public IActionResult Buy(OrderLineItem itemToBuy) { var cookie = new CheckoutCookie(HttpContext.Request.Cookies, HttpContext.Response.Cookies); var service = new CheckoutCookieService(cookie.GetValue()); service.AddLineItem(itemToBuy); cookie.AddOrUpdateCookie(service.EncodeForCookie()); SetupTraceInfo(); return(RedirectToAction(nameof(Index))); }
public IActionResult Buy(OrderLineItem itemToBuy) { var cookie = new BasketCookie( HttpContext.Request.Cookies, HttpContext.Response.Cookies); var service = new CheckoutCookieService(cookie.GetValue()); service.AddLineItem(itemToBuy); var cookieOutString = service.EncodeForCookie(); cookie.AddOrUpdateCookie(cookieOutString); SetupTraceInfo(); //Remove this when shown in book listing return(RedirectToAction("Index")); }
public void AddLineItemEncodeDecode() { //SETUP var service = new CheckoutCookieService((string)null); service.AddLineItem(new OrderLineItem { BookId = 123, NumBooks = 456 }); var cString = service.EncodeForCookie(); //ATTEMPT service = new CheckoutCookieService(cString); //VERIFY service.LineItems.Count.ShouldEqual(1); service.LineItems[0].BookId.ShouldEqual(123); service.LineItems[0].NumBooks.ShouldEqual((short)456); }