50 lines
1.2 KiB
C#
50 lines
1.2 KiB
C#
using DocumentFormat.OpenXml.Office2010.Excel;
|
|
using ShoeStore.Entities.Enums;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Unity;
|
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
|
|
namespace ShoeStore.Entities;
|
|
|
|
public class Sale
|
|
{
|
|
public int Id { get; private set; }
|
|
[DisplayName("Дата продажи")]
|
|
public DateTime DateOfSale { get; private set; }
|
|
|
|
[Browsable(false)]
|
|
public IEnumerable<ProductSale> Product
|
|
{
|
|
get;
|
|
private set;
|
|
} = [];
|
|
|
|
[DisplayName("Продукты")]
|
|
public string Products => Product != null ?
|
|
string.Join(", ", Product.Select(x => $"{x.ProductName}, {x.SalesNumber}")) : string.Empty;
|
|
|
|
public static Sale CreateOperation(int id, DateTime date, IEnumerable<ProductSale> product)
|
|
{
|
|
return new Sale
|
|
{
|
|
Id = id,
|
|
DateOfSale = date,
|
|
Product = product
|
|
};
|
|
}
|
|
|
|
public void SetProductSales (IEnumerable<ProductSale> products)
|
|
{
|
|
if (products != null && products.Any())
|
|
{
|
|
Product = products;
|
|
}
|
|
}
|
|
|
|
}
|