Skip to content

Commit ffa2225

Browse files
update order service function
1 parent 2fda396 commit ffa2225

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

IS_aud/EShop.Service/Implementation/ShoppingCartService.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public ShoppingCartService(IRepository<ShoppingCart> cartRepository, IRepository
3131

3232
public bool DeleteFromCart(Guid id, string userId)
3333
{
34-
var shoppingCart = _cartRepository.Get(selector: x => x, predicate: x => x.OwnerId == id.ToString());
34+
var shoppingCart = _cartRepository.Get(selector: x => x, predicate: x => x.OwnerId == userId);
3535

3636
var productToDelete = _productsInCartsRepository.Get(selector: x => x,
3737
predicate: x => x.ProductId == id && x.ShoppingCartId == shoppingCart.Id);
@@ -43,14 +43,14 @@ public bool DeleteFromCart(Guid id, string userId)
4343

4444
public ShoppingCart GetByUserId(Guid id)
4545
{
46-
return _cartRepository.Get(selector: x => x, predicate: x => x.OwnerId == id.ToString());
46+
return _cartRepository.Get(selector: x => x, predicate: x => x.OwnerId == id.ToString());
4747
}
4848

4949
public ShoppingCartDTO GetByUserIdIncudingProducts(Guid id)
5050
{
5151
var shoppingCart = _cartRepository.Get(selector: x => x,
52-
predicate: x => x.OwnerId == id.ToString(),
53-
include: x => x.Include(y => y.ProductInShoppingCarts).ThenInclude(z => z.Product));
52+
predicate: x => x.OwnerId == id.ToString(),
53+
include: x => x.Include(y => y.ProductInShoppingCarts).ThenInclude(z => z.Product));
5454

5555
var allProducts = shoppingCart.ProductInShoppingCarts.ToList();
5656

@@ -91,8 +91,8 @@ public AddToCartDTO GetProductInfo(Guid id)
9191
public bool OrderProducts(string userId)
9292
{
9393
var shoppingCart = _cartRepository.Get(selector: x => x,
94-
predicate: x => x.OwnerId == userId,
95-
include: x => x.Include(y => y.ProductInShoppingCarts).ThenInclude(z => z.Product));
94+
predicate: x => x.OwnerId == userId,
95+
include: x => x.Include(y => y.ProductInShoppingCarts).ThenInclude(z => z.Product));
9696

9797
var newOrder = new Order
9898
{
@@ -116,7 +116,7 @@ public bool OrderProducts(string userId)
116116

117117
foreach (var product in productsInOrder)
118118
{
119-
total = product.Product.Price * product.Quantity;
119+
total += product.Product.Price * product.Quantity;
120120
_productsInOrderRepository.Insert(product);
121121
}
122122

0 commit comments

Comments
 (0)