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

namespace WhiteList
{
    public partial class Agent
    {
        public string GetIcon
        {
            get => Logo == null ? "Images/picture.png" : Logo;
        }

        public string GetTypeAndTitle
        {
            get => AgentType.Title + " | " + Title;
        }

        public int GetCountSale
        {
            get
            {
                int count = 0;
                foreach(ProductSale ps in DB.dbCon.ProductSale.Where(x=>x.AgentID == ID).ToList())
                {
                    if(ps.SaleDate>=DateTime.Now.AddDays(-365))
                    {
                        count += ps.ProductCount;
                    }
                }
                return count;
            }
        }

        public int GetPercent
        {
            get
            {
                int sale = 0;
                int count = GetCountSale;
                if (count >= 10000)
                {
                    sale = 5;
                }
                if(count>=50000)
                {
                    sale = 10;
                }
                if(count>=150000)
                {
                    sale = 20;
                }
                if (count >= 500000)
                {
                    sale = 25;
                }
                return sale;
            }
        }

        public SolidColorBrush GetBackground
        {
            get => GetPercent >= 25 ? new SolidColorBrush(Color.FromRgb(120, 170, 150)) : new SolidColorBrush(Color.FromRgb(170, 200, 255));
        }
    }

    
}
