2016-11-02 20:41:12 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2017-03-03 16:00:15 +01:00
|
|
|
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
2016-11-02 20:41:12 +01:00
|
|
|
|
{
|
|
|
|
|
public class Basket
|
|
|
|
|
{
|
2017-03-20 14:18:20 -04:00
|
|
|
|
// Use property initializer syntax.
|
|
|
|
|
// While this is often more useful for read only
|
|
|
|
|
// auto implemented properties, it can simplify logic
|
|
|
|
|
// for read/write properties.
|
|
|
|
|
public List<BasketItem> Items { get; set; } = new List<BasketItem>();
|
2016-11-02 20:41:12 +01:00
|
|
|
|
public string BuyerId { get; set; }
|
|
|
|
|
|
|
|
|
|
public decimal Total()
|
|
|
|
|
{
|
2020-12-23 15:19:36 +05:30
|
|
|
|
return Math.Round(Items.Sum(x => x.UnitPrice * x.Quantity), 2);
|
2016-11-02 20:41:12 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|