2024-12-21 10:43:19 +04:00
|
|
|
|
using System.Collections;
|
2024-12-21 15:34:40 +04:00
|
|
|
|
using System.ComponentModel;
|
2024-12-21 10:43:19 +04:00
|
|
|
|
|
|
|
|
|
namespace GasStation.Entities;
|
2024-11-13 23:20:06 +04:00
|
|
|
|
|
|
|
|
|
public class Selling
|
|
|
|
|
{
|
|
|
|
|
public int Id { get; private set; }
|
|
|
|
|
|
2024-12-21 15:34:40 +04:00
|
|
|
|
[Browsable(false)]
|
2024-11-13 23:20:06 +04:00
|
|
|
|
public int GasmanId { get; private set; }
|
|
|
|
|
|
2024-12-21 15:34:40 +04:00
|
|
|
|
[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)]
|
2024-12-02 14:38:24 +04:00
|
|
|
|
public IEnumerable<ProductSelling> ProdutcSellings { get; private set; } = [];
|
|
|
|
|
|
2024-12-21 15:34:40 +04:00
|
|
|
|
[DisplayName("Дата продажи")]
|
2024-11-13 23:20:06 +04:00
|
|
|
|
public DateTime SellingDateTime { get; private set; }
|
|
|
|
|
|
2024-12-21 10:43:19 +04:00
|
|
|
|
public static Selling CreateSelling(int id, int gasmanId, IEnumerable<ProductSelling> produtcSellings)
|
2024-11-13 23:20:06 +04:00
|
|
|
|
{
|
|
|
|
|
return new Selling
|
|
|
|
|
{
|
|
|
|
|
Id = id,
|
|
|
|
|
GasmanId = gasmanId,
|
2024-12-02 14:38:24 +04:00
|
|
|
|
SellingDateTime = DateTime.Now,
|
|
|
|
|
ProdutcSellings = produtcSellings
|
2024-11-13 23:20:06 +04:00
|
|
|
|
};
|
|
|
|
|
}
|
2024-12-21 10:43:19 +04:00
|
|
|
|
|
2024-12-21 15:34:40 +04:00
|
|
|
|
public void SetProductSelling(IEnumerable<ProductSelling> produtcSellings)
|
2024-12-21 10:43:19 +04:00
|
|
|
|
{
|
2024-12-21 15:34:40 +04:00
|
|
|
|
if (produtcSellings != null && produtcSellings.Any())
|
2024-12-21 10:43:19 +04:00
|
|
|
|
{
|
2024-12-21 15:34:40 +04:00
|
|
|
|
ProdutcSellings = produtcSellings;
|
|
|
|
|
}
|
2024-12-21 10:43:19 +04:00
|
|
|
|
}
|
2024-11-13 23:20:06 +04:00
|
|
|
|
}
|