ShopPlatform.Web 1.0.0.0
농산물, 소프트웨어 라이선스와 개발 용역을 직접 판매하는 CodeMaru 직영 쇼핑몰입니다.
로딩중...
검색중...
일치하는것 없음
ShopPlatform.Services.CartService 클래스 참조sealed

더 자세히 ...

Public 멤버 함수

void Add (Product product, int quantity=1)
void Remove (int productId)
void UpdateQuantity (int productId, int quantity)
void Clear ()

속성

IReadOnlyList< CartItemItems [get]
decimal Total [get]
int Count [get]

Private 속성

readonly List< CartItem_items = new()

상세한 설명

세션 기반 장바구니 (Scoped). 실제 앱에서는 Blazor Server 회로 수명에 맞춤.

CartService.cs 파일의 13 번째 라인에서 정의되었습니다.

멤버 함수 문서화

◆ Add()

void ShopPlatform.Services.CartService.Add ( Product product,
int quantity = 1 )
inline

항목을 추가합니다.

매개변수
productproduct에 사용할 Product 값입니다.
quantityquantity에 사용할 int 값입니다.

CartService.cs 파일의 77 번째 라인에서 정의되었습니다.

78 {
79 var existing = _items.FirstOrDefault(i => i.ProductId == product.Id);
80 if (existing != null)
81 existing.Quantity += quantity;
82 else
83 _items.Add(new CartItem
84 {
85 ProductId = product.Id,
86 ProductName = product.Name,
87 UnitPrice = product.Price,
88 Quantity = quantity
89 });
90 }

다음을 참조함 : _items, ShopPlatform.Models.Product.Id, ShopPlatform.Models.Product.Name, ShopPlatform.Models.Product.Price.

◆ Clear()

void ShopPlatform.Services.CartService.Clear ( )
inline

Clear 작업을 수행합니다.

CartService.cs 파일의 151 번째 라인에서 정의되었습니다.

151=> _items.Clear();

다음을 참조함 : _items.

◆ Remove()

void ShopPlatform.Services.CartService.Remove ( int productId)
inline

항목을 제거합니다.

매개변수
productIdproduct Id에 사용할 int 값입니다.

CartService.cs 파일의 108 번째 라인에서 정의되었습니다.

109 => _items.RemoveAll(i => i.ProductId == productId);

다음을 참조함 : _items.

다음에 의해서 참조됨 : UpdateQuantity().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ UpdateQuantity()

void ShopPlatform.Services.CartService.UpdateQuantity ( int productId,
int quantity )
inline

Update Quantity 작업을 수행합니다.

매개변수
productIdproduct Id에 사용할 int 값입니다.
quantityquantity에 사용할 int 값입니다.

CartService.cs 파일의 135 번째 라인에서 정의되었습니다.

136 {
137 var item = _items.FirstOrDefault(i => i.ProductId == productId);
138 if (item == null) return;
139 if (quantity <= 0) Remove(productId);
140 else item.Quantity = quantity;
141 }

다음을 참조함 : _items, Remove().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

멤버 데이터 문서화

◆ _items

readonly List<CartItem> ShopPlatform.Services.CartService._items = new()
private

items 값을 보관합니다.

CartService.cs 파일의 23 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : Add(), Clear(), Remove(), UpdateQuantity().

속성 문서화

◆ Count

int ShopPlatform.Services.CartService.Count
get

Count 값을 가져옵니다.

CartService.cs 파일의 51 번째 라인에서 정의되었습니다.

◆ Items

IReadOnlyList<CartItem> ShopPlatform.Services.CartService.Items
get

Items 값을 가져옵니다.

CartService.cs 파일의 33 번째 라인에서 정의되었습니다.

◆ Total

decimal ShopPlatform.Services.CartService.Total
get

Total 값을 가져옵니다.

CartService.cs 파일의 42 번째 라인에서 정의되었습니다.


이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: