PartAgent.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ProbnikDemo
  7. {
  8. public partial class Agent
  9. {
  10. public string BackGround { get; set; }
  11. public string AgentTypes { get; set; }
  12. public string CountSale { get; set;}
  13. public List<Agent> Agents()
  14. {
  15. List<Agent> agents = BaseConnect.BaseModel.Agent.ToList();
  16. List<ProductSale> productSales = BaseConnect.BaseModel.ProductSale.ToList();
  17. List<Product> products = BaseConnect.BaseModel.Product.ToList();
  18. Random r = new Random();
  19. foreach (Agent a in agents)
  20. {
  21. AgentType agentType = BaseConnect.BaseModel.AgentType.FirstOrDefault(x => x.ID == a.AgentTypeID);
  22. a.AgentTypes = agentType.Title;
  23. foreach (ProductSale sales in productSales)
  24. {
  25. if (a.ID == sales.AgentID)
  26. {
  27. a.CountSale = Convert.ToString(sales.ProductCount);
  28. if (CountSale == "")
  29. {
  30. CountSale = "20";
  31. }
  32. }
  33. }
  34. }
  35. return agents;
  36. }
  37. }
  38. }