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<Agent> Agents()
        {
            List<Agent> agents = BaseConnect.BaseModel.Agent.ToList();
            List<ProductSale> productSales = BaseConnect.BaseModel.ProductSale.ToList();
            List<Product> products = BaseConnect.BaseModel.Product.ToList();
            Random r = new Random();
            foreach (Agent a in agents)
            {
                if( a.Logo == ""){
                    a.Logo = "/agents/picture.png";
                }
                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;
        }
    }
}
