50 lines
1.2 KiB
C#
Raw Normal View History

2024-12-23 16:41:52 +04:00
using DocumentFormat.OpenXml.Office2010.Excel;
using ShoeStore.Entities.Enums;
2024-11-29 15:40:02 +04:00
using System;
using System.Collections.Generic;
2024-12-23 17:55:39 +04:00
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2024-12-23 16:41:52 +04:00
using Unity;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace ShoeStore.Entities;
public class Sale
{
public int Id { get; private set; }
2024-12-23 17:55:39 +04:00
[DisplayName("Дата продажи")]
public DateTime DateOfSale { get; private set; }
2024-12-23 17:55:39 +04:00
[Browsable(false)]
public IEnumerable<ProductSale> Product
{
get;
private set;
} = [];
2024-12-23 17:55:39 +04:00
[DisplayName("Продукты")]
public string Products => Product != null ?
string.Join(", ", Product.Select(x => $"{x.ProductName}, {x.SalesNumber}")) : string.Empty;
2024-12-23 16:41:52 +04:00
public static Sale CreateOperation(int id, DateTime date, IEnumerable<ProductSale> product)
{
return new Sale
{
Id = id,
2024-12-21 21:15:47 +04:00
DateOfSale = date,
Product = product
};
}
2024-12-23 17:55:39 +04:00
public void SetProductSales (IEnumerable<ProductSale> products)
2024-12-23 16:41:52 +04:00
{
2024-12-23 17:55:39 +04:00
if (products != null && products.Any())
2024-12-23 16:41:52 +04:00
{
2024-12-23 17:55:39 +04:00
Product = products;
}
2024-12-23 16:41:52 +04:00
}
}