public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { var cart = (Cart)controllerContext.HttpContext.Session[Constants.CartKey]; if (cart == null) { cart = new Cart(); controllerContext.HttpContext.Session[Constants.CartKey] = cart; } return cart; }
protected override void Initialize(RequestContext requestContext) { base.Initialize(requestContext); var cart = (Cart) ControllerContext.HttpContext.Session[Constants.CartKey]; if (cart == null) { cart = new Cart(); ControllerContext.HttpContext.Session[Constants.CartKey] = cart; } Cart = cart; RefreshCart(); }