⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sessionshoppingcartcontroller.vb

📁 C#语言制作asp.net网上商店的
💻 VB
字号:
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.Web


Namespace NetShopForge.Library.Cart

    Public Class SessionShoppingCartController
        Implements IShoppingCart

        'ToDo: Add Implements Clauses for implementation methods of these interface(s)
        Public Function Add(ByVal cartid As String, ByVal item As IShoppingCartInfo) As Integer Implements IShoppingCart.Add
            Dim items As List(Of ShoppingCartInfo)
            If Not (HttpContext.Current.Session("mycart") Is Nothing) Then
                items = CType(HttpContext.Current.Session("mycart"), List(Of ShoppingCartInfo))
                If items.Contains(item) Then items.Remove(item)
            Else
                items = New List(Of ShoppingCartInfo)
                ' HttpContext.Current.Session("mycart") = items
            End If
            items.Add(item)
            HttpContext.Current.Session("mycart") = items
            Return 0
        End Function 'Add

        Public Function Remove(ByVal cartid As String, ByVal item As IShoppingCartInfo) As Integer Implements IShoppingCart.Remove
            Dim items As List(Of ShoppingCartInfo) = CType(HttpContext.Current.Session("mycart"), List(Of ShoppingCartInfo))
            Dim i As Integer
            For i = 0 To items.Count - 1
                If CType(items(i), IShoppingCartInfo).ProductID = item.ProductID Then
                    items.RemoveAt(i)
                    Exit For
                End If
            Next i
            Return 0
        End Function 'Remove




        Public Function GetItems(ByVal cartid As String) As System.Collections.Generic.IList(Of IShoppingCartInfo) Implements IShoppingCart.GetItems
            Return CType(HttpContext.Current.Session("mycart"), IList(Of IShoppingCartInfo))
        End Function
    End Class
End Namespace

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -