PIbd-21_Tarasov_V.D._Optika/ProjectOptika/Scripts/Entities/Order.cs

56 lines
1.8 KiB
C#

using System.ComponentModel;
namespace ProjectOptika.Scripts.Entities
{
public class Order
{
public int ID { get; private set; }
[Browsable(false)]
public int EmployeeID { get; private set; }
[Browsable(false)]
public int ClientID { get; private set; }
[DisplayName("Дата заказа")]
public DateTime OrderDate { get; private set; }
[DisplayName("Общая стоимость")]
public double TotalCost { get; private set; }
[DisplayName("Клиент")]
public string ClientFullName { get; private set; }
[DisplayName("Работник")]
public string EmployeeFullName { get; private set; }
[DisplayName("Заказ")]
public string AccessoryOrder => AccesoriesOrders != null ?
string.Join(", ", AccesoriesOrders.Select(x => x != null ? $"{x.AccessoryName} {x.Count}" : string.Empty)) :
string.Empty;
[Browsable(false)]
public IEnumerable<AccessoriesOrder> AccesoriesOrders { get; private set; } = [];
public void SetAccessriesOrderReplenishment(IEnumerable<AccessoriesOrder> accesoriesOrders)
{
if (accesoriesOrders != null && accesoriesOrders.Any())
{
AccesoriesOrders = accesoriesOrders;
}
}
public static Order CreateOperation(int id, int employeeID, int clientID, double totalCost, IEnumerable<AccessoriesOrder> accesoriesOrders)
{
return new Order {
ID = id,
EmployeeID = employeeID,
ClientID = clientID,
OrderDate = DateTime.Now,
TotalCost = totalCost,
AccesoriesOrders = accesoriesOrders
};
}
}
}