using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IronIntel.Services;
using IronIntel.Contractor.Users;
using IronIntel.Services.MapView;
using IronIntel.Services.Customers;

namespace IronIntel.Contractor.MapView
{
    public static class MapViewer
    {
        public static KeyValuePair<string, string>[] GetContractors(string useriid)
        {
            Users.UserInfo userinfo = UserManagement.GetUserByIID(useriid);
            CustomerInfo[] cps = SystemParams.GetContractors();
            List<KeyValuePair<string, string>> ls = new List<KeyValuePair<string, string>>();
            if (userinfo.UserType == UserTypes.Admin || userinfo.UserType == UserTypes.SupperAdmin)
            {
                foreach (CustomerInfo cp in cps)
                {
                    ls.Add(new KeyValuePair<string, string>(cp.ID, cp.Name));
                }
            }
            else
            {
                string[] str = Acl.GetUserAvailableContractors(useriid);
                foreach (CustomerInfo cp in cps)
                {
                    foreach (string s in str)
                    {
                        if (string.Compare(cp.ID, s, true) == 0)
                        {
                            ls.Add(new KeyValuePair<string, string>(cp.ID, cp.Name));
                            break;
                        }
                    }
                }
            }
            return ls.ToArray();
        }
    }
}
