using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProbnikDemo { public partial class Agent { public string BackGround { get; set; } public string AgentTypes { get; set; } public string CountSale { get; set;} public List Agents() { List agents = BaseConnect.BaseModel.Agent.ToList(); List productSales = BaseConnect.BaseModel.ProductSale.ToList(); List products = BaseConnect.BaseModel.Product.ToList(); Random r = new Random(); foreach (Agent a in agents) { AgentType agentType = BaseConnect.BaseModel.AgentType.FirstOrDefault(x => x.ID == a.AgentTypeID); a.AgentTypes = agentType.Title; foreach (ProductSale sales in productSales) { if (a.ID == sales.AgentID) { a.CountSale = Convert.ToString(sales.ProductCount); if (CountSale == "") { CountSale = "20"; } } } } return agents; } } }