using System; using System.Collections.Generic; using System.Linq; namespace tiron_demo.Models; public partial class Partner { public int Id { get; set; } public string Name { get; set; } = null!; public string Director { get; set; } = null!; public string? Email { get; set; } public string? Phone { get; set; } public string? Address { get; set; } public string? Inn { get; set; } public short Rating { get; set; } public int Type { get; set; } public int Discount => GetDiscount(); public virtual ICollection PartnerProducts { get; set; } = new List(); public virtual PartnerType TypeNavigation { get; set; } = null!; private int GetDiscount() { int sum = PartnerProducts.Select(x => x.Amount).Sum(); if (sum < 10000) { return 0; } else if (sum < 50000) { return 5; } else if (sum < 300000) { return 10; } else { return 15; } } }