Wonky.Client/Wonky.Entity/Models/Draft.cs

37 lines
890 B
C#
Raw Normal View History

2022-03-15 12:04:15 +01:00
using Wonky.Entity.DTO;
2022-03-15 12:04:15 +01:00
namespace Wonky.Entity.Models;
2022-03-15 18:11:01 +01:00
public class DraftItem
{
public int Quantity { get; set; }
2022-03-15 12:04:15 +01:00
public SalesItemDto Item { get; set; }
public decimal Price { get; set; }
public decimal Total
{
get
{
2022-03-15 12:04:15 +01:00
var price = (from x in Item.Rates where x.Quantity == Quantity.ToString() select x.Rate).First();
if (string.IsNullOrWhiteSpace(price))
price = Item.Rates[0].Rate;
Price = Convert.ToDecimal(price);
return Price * Quantity;
}
}
}
2022-03-15 18:11:01 +01:00
public class Draft
{
2022-03-15 18:11:01 +01:00
public List<DraftItem> Items { get; set; } = new List<DraftItem>();
public decimal Total
{
get
{
return Items.Sum(item => item.Total);
}
}
public DateTime LastAccessed { get; set; }
2022-03-15 18:11:01 +01:00
public int TimeToLiveInSeconds { get; set; } = 300; // default
}