PartialAgent.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ExamTry
  7. {
  8. public partial class Agent
  9. {
  10. public string GetImage
  11. {
  12. get
  13. {
  14. if (Logo == "")
  15. return Environment.CurrentDirectory + "/agents/picture.png";
  16. else
  17. return Environment.CurrentDirectory + Logo;
  18. }
  19. }
  20. public int GetProductionYear
  21. {
  22. get
  23. {
  24. int productYear = 0;
  25. List<ProductSale> Ps = BaseConnect.BaseModel.ProductSale.Where(x => ID == x.AgentID).ToList();
  26. foreach (var item in Ps)
  27. {
  28. if (item.SaleDate.Year == DateTime.Now.Year)
  29. {
  30. productYear += item.ProductCount;
  31. }
  32. }
  33. return productYear;
  34. }
  35. }
  36. public int GetProductionSale
  37. {
  38. get
  39. {
  40. int summAgent = 0;
  41. List<ProductSale> Ps = BaseConnect.BaseModel.ProductSale.Where(x => ID == x.AgentID).ToList();
  42. foreach (var item in Ps)
  43. {
  44. int cost = (int)BaseConnect.BaseModel.Product.FirstOrDefault(x => x.ID == item.ProductID).MinCostForAgent;
  45. summAgent += item.ProductID * cost;
  46. }
  47. if (summAgent > 0 && summAgent < 10000)
  48. {
  49. return 0;
  50. };
  51. if (summAgent > 10000 && summAgent < 50000)
  52. {
  53. return 5;
  54. };
  55. if (summAgent > 50000 && summAgent < 150000)
  56. {
  57. return 10;
  58. };
  59. if (summAgent > 150000 && summAgent < 500000)
  60. {
  61. return 20;
  62. };
  63. if (summAgent > 500000)
  64. {
  65. return 25;
  66. };
  67. return 25;
  68. }
  69. }
  70. public bool greenSale { get => GetProductionSale == 25; }
  71. }
  72. }