55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ProjectAtelier.Entities;
|
|
|
|
public class Product
|
|
{
|
|
public int Id { get; set; }
|
|
|
|
[DisplayName("Название")]
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
[DisplayName("Вид")]
|
|
public ProductView View{ get; set; }
|
|
|
|
public string FullProductName => $"{Name} {View}";
|
|
|
|
[DisplayName("Количество ")]
|
|
public int CountMaterial { get; set; }
|
|
|
|
|
|
[DisplayName("Материалы")]
|
|
public string Products => ProductMaterial != null ?
|
|
string.Join(", ", ProductMaterial.Select(x => $"{x.MaterialName} {x.Count}")) : string.Empty;
|
|
|
|
[Browsable(false)]
|
|
public IEnumerable<ProductMaterial> ProductMaterial { get; set; } = [];
|
|
|
|
|
|
public static Product CreateEntity(int id, string name, ProductView view, int countmaterial, IEnumerable<ProductMaterial> productMaterial)
|
|
{
|
|
return new Product
|
|
{
|
|
Id = id,
|
|
Name = name,
|
|
View = view,
|
|
CountMaterial = countmaterial,
|
|
ProductMaterial = productMaterial
|
|
};
|
|
}
|
|
public void SetProductMaterial(IEnumerable<ProductMaterial> productMaterial)
|
|
{
|
|
if (productMaterial != null && productMaterial.Any())
|
|
{
|
|
ProductMaterial = productMaterial;
|
|
}
|
|
}
|
|
|
|
}
|
|
|