using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DemoTest_Boldin_41P { class VMMAgent { public List createList() { List listAgent = BaseConnect.BaseModel.Agent.ToList(); foreach (Agent a in listAgent) { DateTime dtt = DateTime.Now; DateTime dt = dtt.AddDays(-365); int countpr = 0; List ps = BaseConnect.BaseModel.ProductSale.Where(x => x.AgentID == a.ID && x.SaleDate >= dt && x.SaleDate <= dtt).ToList(); List psale = BaseConnect.BaseModel.ProductSale.Where(x => x.AgentID == a.ID).ToList(); foreach (ProductSale p in ps) { a.CountSale +=p.ProductCount; } foreach(ProductSale pss in psale) { countpr += pss.ProductCount; } if(countpr >10000 && countpr<50000) { a.Sale = 5; } if (countpr > 50000 && countpr < 150000) { a.Sale = 10; } if (countpr > 150000 && countpr < 500000) { a.Sale = 20; } if (countpr > 500000) { a.Sale = 25; } if (a.Logo == "") { a.Logo = @"images\picture.png"; } AgentType at = BaseConnect.BaseModel.AgentType.FirstOrDefault(x => x.ID == a.AgentTypeID); a.NameTypeAgent = at.Title; } return listAgent; } } }