using ProjectRepairWork.Entities.Enums; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProjectRepairWork.Entities; public class Repair { public int Id { get; private set; } [Browsable(false)] public int ContractorsId { get; private set; } [Browsable(false)] public int PremisesId { get; private set; } [DisplayName("Подрядчик")] public string CompanyName { get; private set; } = string.Empty; [Browsable(false)] public int PremisesType { get; private set; } [DisplayName("Помещение")] public string PremisesName => $"{(PremisesType)PremisesType}"; [DisplayName("Дата ремонта")] public DateTime DateRepair { get; private set; } public string RepairRepair => RepairRepairList != null ? string.Join(" ,", RepairRepairList.Select(x => $"{x.WorkName} {x.Count}")) : string.Empty; [Browsable(false)] public List RepairRepairList { get; private set; } = new List(); public static Repair CreatOpertions(int id, int contractorsId, DateTime dateRepair, int premisesId, IEnumerable repairRepair) { return new Repair { Id = id, ContractorsId = contractorsId, PremisesId = premisesId, DateRepair = dateRepair, RepairRepairList = repairRepair.ToList(), }; } public void SetRepairRepairList(IEnumerable repairRepair) { if (repairRepair != null && repairRepair.Any()) { RepairRepairList = repairRepair.ToList(); } } }