2022-03-15 12:04:15 +01:00
|
|
|
using Wonky.Entity.DTO;
|
2022-03-14 17:59:22 +01:00
|
|
|
|
2022-03-15 12:04:15 +01:00
|
|
|
namespace Wonky.Entity.Models;
|
2022-03-14 17:59:22 +01:00
|
|
|
|
2022-03-15 18:11:01 +01:00
|
|
|
public class DraftItem
|
2022-03-14 17:59:22 +01:00
|
|
|
{
|
|
|
|
public int Quantity { get; set; }
|
2022-03-15 12:04:15 +01:00
|
|
|
public SalesItemDto Item { get; set; }
|
|
|
|
public decimal Price { get; set; }
|
2022-03-14 17:59:22 +01:00
|
|
|
|
|
|
|
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-14 17:59:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-15 18:11:01 +01:00
|
|
|
public class Draft
|
2022-03-14 17:59:22 +01:00
|
|
|
{
|
2022-03-15 18:11:01 +01:00
|
|
|
public List<DraftItem> Items { get; set; } = new List<DraftItem>();
|
2022-03-14 17:59:22 +01:00
|
|
|
|
|
|
|
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
|
2022-03-14 17:59:22 +01:00
|
|
|
}
|