using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BuzuevaDemo.Classes
{
    class ViewModel
    {
        public List<Agent> agent;
        public ViewModel()
        {
            agent = ListAgent();
        }
         public List<Agent> ListAgent()
        {
            List <Agent> agents = new List<Agent>();
            Agent buffag;
            List<Agent> bdagent = DataBase.BaseModel.Agent.ToList();
            List<AgentType> bdagenttype = DataBase.BaseModel.AgentType.ToList();
            List<ProductSale> bdproductSales = DataBase.BaseModel.ProductSale.ToList();
            List<Product> bdproduct = DataBase.BaseModel.Product.ToList();
            foreach (Agent bda in bdagent)
            {
                //извлечение данных тип агента
                AgentType AT = DataBase.BaseModel.AgentType.FirstOrDefault(x => x.ID == bda.AgentTypeID);
                bda.TitleType = AT.Title; 
                int skid = 0;
                buffag = new Agent();
                buffag.Title = bda.Title;
                buffag.Phone = bda.Phone;
                buffag.Priority = bda.Priority;
                buffag.Logo = bda.Logo;
                // картинка-загушка
                if (bda.Logo == "")
                {
                    bda.Logo = "/agents/picture.png";
                }
                agents.Add(buffag); ;
            }
            agents = DataBase.BaseModel.Agent.ToList();
            return agents;
        }

    }
}
