123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DemoTest_Boldin_41P
- {
- class VMMAgent
- {
- public List<Agent> createList()
- {
- List<Agent> listAgent = BaseConnect.BaseModel.Agent.ToList();
- foreach (Agent a in listAgent)
- {
- DateTime dtt = DateTime.Now;
- DateTime dt = dtt.AddDays(-365);
- int countpr = 0;
- List<ProductSale> ps = BaseConnect.BaseModel.ProductSale.Where(x => x.AgentID == a.ID && x.SaleDate >= dt && x.SaleDate <= dtt).ToList();
- List<ProductSale> 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;
- }
- }
- }
|