@@ -31,7 +31,7 @@ public ShoppingCartService(IRepository<ShoppingCart> cartRepository, IRepository
31
31
32
32
public bool DeleteFromCart ( Guid id , string userId )
33
33
{
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 ) ;
35
35
36
36
var productToDelete = _productsInCartsRepository . Get ( selector : x => x ,
37
37
predicate : x => x . ProductId == id && x . ShoppingCartId == shoppingCart . Id ) ;
@@ -43,14 +43,14 @@ public bool DeleteFromCart(Guid id, string userId)
43
43
44
44
public ShoppingCart GetByUserId ( Guid id )
45
45
{
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 ( ) ) ;
47
47
}
48
48
49
49
public ShoppingCartDTO GetByUserIdIncudingProducts ( Guid id )
50
50
{
51
51
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 ) ) ;
54
54
55
55
var allProducts = shoppingCart . ProductInShoppingCarts . ToList ( ) ;
56
56
@@ -91,8 +91,8 @@ public AddToCartDTO GetProductInfo(Guid id)
91
91
public bool OrderProducts ( string userId )
92
92
{
93
93
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 ) ) ;
96
96
97
97
var newOrder = new Order
98
98
{
@@ -116,7 +116,7 @@ public bool OrderProducts(string userId)
116
116
117
117
foreach ( var product in productsInOrder )
118
118
{
119
- total = product . Product . Price * product . Quantity ;
119
+ total + = product . Product . Price * product . Quantity ;
120
120
_productsInOrderRepository . Insert ( product ) ;
121
121
}
122
122
0 commit comments