VMMAgent.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace DemoTest_Boldin_41P
  7. {
  8. class VMMAgent
  9. {
  10. public List<Agent> createList()
  11. {
  12. List<Agent> listAgent = BaseConnect.BaseModel.Agent.ToList();
  13. foreach (Agent a in listAgent)
  14. {
  15. DateTime dtt = DateTime.Now;
  16. DateTime dt = dtt.AddDays(-365);
  17. int countpr = 0;
  18. List<ProductSale> ps = BaseConnect.BaseModel.ProductSale.Where(x => x.AgentID == a.ID && x.SaleDate >= dt && x.SaleDate <= dtt).ToList();
  19. List<ProductSale> psale = BaseConnect.BaseModel.ProductSale.Where(x => x.AgentID == a.ID).ToList();
  20. foreach (ProductSale p in ps)
  21. {
  22. a.CountSale +=p.ProductCount;
  23. }
  24. foreach(ProductSale pss in psale)
  25. {
  26. countpr += pss.ProductCount;
  27. }
  28. if(countpr >10000 && countpr<50000)
  29. {
  30. a.Sale = 5;
  31. }
  32. if (countpr > 50000 && countpr < 150000)
  33. {
  34. a.Sale = 10;
  35. }
  36. if (countpr > 150000 && countpr < 500000)
  37. {
  38. a.Sale = 20;
  39. }
  40. if (countpr > 500000)
  41. {
  42. a.Sale = 25;
  43. }
  44. if (a.Logo == "")
  45. {
  46. a.Logo = @"images\picture.png";
  47. }
  48. AgentType at = BaseConnect.BaseModel.AgentType.FirstOrDefault(x => x.ID == a.AgentTypeID);
  49. a.NameTypeAgent = at.Title;
  50. }
  51. return listAgent;
  52. }
  53. }
  54. }