demo2025_products_tiron_baby/Models/Product.cs
Your Name 4ba7d31e91 demo
2025-03-25 15:37:37 +03:00

44 lines
1.1 KiB
C#

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<PartnerProduct> PartnerProducts { get; set; } = new List<PartnerProduct>();
public virtual ICollection<ProductsMinCostHistory> ProductsMinCostHistories { get; set; } = new List<ProductsMinCostHistory>();
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");
}
}
}