44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.ComponentModel;
|
|
|
|
namespace GasStation.Entities;
|
|
|
|
public class Selling
|
|
{
|
|
public int Id { get; private set; }
|
|
|
|
[Browsable(false)]
|
|
public int GasmanId { get; private set; }
|
|
|
|
[DisplayName("Имя заправщика")]
|
|
public string GasmanName { get; private set; } = string.Empty;
|
|
|
|
[DisplayName("Товары")]
|
|
public string Product => ProdutcSellings != null ? string.Join(", ", ProdutcSellings.Select(x => $"{x.ProductName} {x.Count}")) : string.Empty;
|
|
|
|
[Browsable(false)]
|
|
public IEnumerable<ProductSelling> ProdutcSellings { get; private set; } = [];
|
|
|
|
[DisplayName("Дата продажи")]
|
|
public DateTime SellingDateTime { get; private set; }
|
|
|
|
public static Selling CreateSelling(int id, int gasmanId, IEnumerable<ProductSelling> produtcSellings)
|
|
{
|
|
return new Selling
|
|
{
|
|
Id = id,
|
|
GasmanId = gasmanId,
|
|
SellingDateTime = DateTime.Now,
|
|
ProdutcSellings = produtcSellings
|
|
};
|
|
}
|
|
|
|
public void SetProductSelling(IEnumerable<ProductSelling> produtcSellings)
|
|
{
|
|
if (produtcSellings != null && produtcSellings.Any())
|
|
{
|
|
ProdutcSellings = produtcSellings;
|
|
}
|
|
}
|
|
}
|