public ActionResult RemoveFromCompare(int productId) { CompareManager compareManager = new CompareManager(this.sessionCompare, this.db); int itemCount = compareManager.RemoveFromCompare(productId); db.SaveChanges(); var compareItems = compareManager.GetCompare(); //ilosc elem aktualnie w koszyku // Return JSON to process it in JavaScript //struktura //ktora ma zostac zwrocona po wcisniecie remove //var result = new CompareRemoveViewModel //{ // RemoveItemId = productId, // RemovedItemCount = itemCount, //}; CompareViewModel compareVM = new CompareViewModel() { CompareItems = compareItems }; return(Json(compareVM)); //return Json(result, JsonRequestBehavior.AllowGet); }
public ActionResult Compare() { //sesja i kontekst jako param. CompareManager compareManager = new CompareManager(this.sessionCompare, this.db); //zwraca liste cartItem ktora w tym momencie jest zapisana w sesji //pobieramy stan koszyka var compareItems = compareManager.GetCompare(); //ustawiany na to co pobralismy CompareViewModel compareVM = new CompareViewModel() { CompareItems = compareItems }; return(View(compareVM)); // return Json(compareVM); }