using Avalonia.Media; using System; using System.Collections.Generic; using System.Linq; namespace tiron_demo.Models; public partial class Product { public int Id { get; set; } public int Type { get; set; } public string Name { get; set; } = null!; public string Articul { get; set; } = null!; public float MinCost { get; set; } public SolidColorBrush ProductBackground => GetProductBackground(); public virtual ICollection PartnerProducts { get; set; } = new List(); public virtual ICollection ProductsMinCostHistories { get; set; } = new List(); public virtual ProductType TypeNavigation { get; set; } = null!; private SolidColorBrush GetProductBackground() { int sum = PartnerProducts.Where(x => x.SellDate.Value.Year == 2024).Sum(x => x.Amount); if (sum < 10000) { return SolidColorBrush.Parse("Red"); } else if (sum < 60000) { return SolidColorBrush.Parse("Orange"); } else { return SolidColorBrush.Parse("Green"); } } }