Merge branch 'release' into dev
This commit is contained in:
commit
ef92bf3834
|
|
@ -76,19 +76,29 @@ namespace MusicStore.Controllers
|
||||||
.Include(c => c.Album)
|
.Include(c => c.Album)
|
||||||
.SingleOrDefaultAsync();
|
.SingleOrDefaultAsync();
|
||||||
|
|
||||||
// Remove from cart
|
string message;
|
||||||
int itemCount = cart.RemoveFromCart(id);
|
int itemCount;
|
||||||
|
if (cartItem != null)
|
||||||
|
{
|
||||||
|
// Remove from cart
|
||||||
|
itemCount = cart.RemoveFromCart(id);
|
||||||
|
|
||||||
await DbContext.SaveChangesAsync(requestAborted);
|
await DbContext.SaveChangesAsync(requestAborted);
|
||||||
|
|
||||||
string removed = (itemCount > 0) ? " 1 copy of " : string.Empty;
|
string removed = (itemCount > 0) ? " 1 copy of " : string.Empty;
|
||||||
|
message = removed + cartItem.Album.Title + " has been removed from your shopping cart.";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemCount = 0;
|
||||||
|
message = "Could not find this item, nothing has been removed from your shopping cart.";
|
||||||
|
}
|
||||||
|
|
||||||
// Display the confirmation message
|
// Display the confirmation message
|
||||||
|
|
||||||
var results = new ShoppingCartRemoveViewModel
|
var results = new ShoppingCartRemoveViewModel
|
||||||
{
|
{
|
||||||
Message = removed + cartItem.Album.Title +
|
Message = message,
|
||||||
" has been removed from your shopping cart.",
|
|
||||||
CartTotal = await cart.GetTotal(),
|
CartTotal = await cart.GetTotal(),
|
||||||
CartCount = await cart.GetCount(),
|
CartCount = await cart.GetCount(),
|
||||||
ItemCount = itemCount,
|
ItemCount = itemCount,
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ namespace MusicStore.Models
|
||||||
public int RemoveFromCart(int id)
|
public int RemoveFromCart(int id)
|
||||||
{
|
{
|
||||||
// Get the cart
|
// Get the cart
|
||||||
var cartItem = _dbContext.CartItems.Single(
|
var cartItem = _dbContext.CartItems.SingleOrDefault(
|
||||||
cart => cart.CartId == _shoppingCartId
|
cart => cart.CartId == _shoppingCartId
|
||||||
&& cart.CartItemId == id);
|
&& cart.CartItemId == id);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue