AgentPartial.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace DemoexamUser11
  7. {
  8. public partial class Agent
  9. {
  10. public string ImagePath { get => Logo == "" ? "/images/picture.png" : Logo; }
  11. public string Type { get => AgentType.Title; }
  12. public string SaleYear { get => ProductSale.Where(x => x.AgentID == ID && DateTime.Now.Year - x.SaleDate.Year < 2).ToList().Count.ToString() + " продаж за год"; }
  13. public string PriorityText { get => "Приоритетность: " + Priority; }
  14. public string Descount
  15. {
  16. get
  17. {
  18. List<ProductSale> productSales = ProductSale.Where(x => x.AgentID == ID).ToList();
  19. int summ = 0;
  20. int descount = 0;
  21. foreach (var productSale in productSales)
  22. {
  23. summ += productSale.ProductCount;
  24. }
  25. if (summ > 10000 && summ < 50000)
  26. descount = 5;
  27. else if (summ > 50000 && summ < 150000)
  28. descount = 10;
  29. else if (summ > 150000 && summ < 500000)
  30. descount = 20;
  31. else if (summ > 500000)
  32. descount = 25;
  33. return descount.ToString();
  34. }
  35. }
  36. }
  37. }