Merge branch 'release' into dev

This commit is contained in:
David Obando 2016-05-12 16:32:47 -07:00
commit ef92bf3834
2 changed files with 17 additions and 7 deletions

View File

@ -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,

View File

@ -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);