Cart Updates (#26)
* ardalis/cart-updates Updating how items are added to cart and displayed in cart. * Cleaning up UI
This commit is contained in:
19
src/Web/ViewModels/BasketItemViewModel.cs
Normal file
19
src/Web/ViewModels/BasketItemViewModel.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.eShopWeb.ViewModels
|
||||
{
|
||||
|
||||
public class BasketItemViewModel
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string ProductId { get; set; }
|
||||
public string ProductName { get; set; }
|
||||
public decimal UnitPrice { get; set; }
|
||||
public decimal OldUnitPrice { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
public string PictureUrl { get; set; }
|
||||
}
|
||||
}
|
||||
18
src/Web/ViewModels/BasketViewModel.cs
Normal file
18
src/Web/ViewModels/BasketViewModel.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.eShopWeb.ViewModels
|
||||
{
|
||||
|
||||
public class BasketViewModel
|
||||
{
|
||||
public List<BasketItemViewModel> Items { get; set; } = new List<BasketItemViewModel>();
|
||||
public string BuyerId { get; set; }
|
||||
|
||||
public decimal Total()
|
||||
{
|
||||
return Math.Round(Items.Sum(x => x.UnitPrice * x.Quantity), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user