using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MySystem.Models;

namespace MySystem
{
    public sealed class DictionaryClass
    {
        Models.WebCMSEntities db = new Models.WebCMSEntities();
        BsModels.WebCMSEntities bsdb = new BsModels.WebCMSEntities();

        #region Col字典

        public Dictionary<string, string> getColDic()
        {
            List<BsModels.Col> ColList = bsdb.Col.ToList();
            Dictionary<string, string> ColDic = new Dictionary<string, string>();
            foreach (BsModels.Col subCol in ColList)
            {
                ColDic.Add(subCol.ColId.ToString(), subCol.ColName.ToString());
            }
            return ColDic;
        }

        #endregion


        #region MsgTemplate字典

        public Dictionary<string, string> getMsgTemplateDic()
        {
            List<MsgTemplate> MsgTemplateList = db.MsgTemplate.ToList();
            Dictionary<string, string> MsgTemplateDic = new Dictionary<string, string>();
            foreach (MsgTemplate subMsgTemplate in MsgTemplateList)
            {
                MsgTemplateDic.Add(subMsgTemplate.Id.ToString(), subMsgTemplate.Title.ToString());
            }
            return MsgTemplateDic;
        }

        #endregion


        #region ProductFareTemp字典

        public Dictionary<string, string> getProductFareTempDic()
        {
            List<ProductFareTemp> ProductFareTempList = db.ProductFareTemp.ToList();
            Dictionary<string, string> ProductFareTempDic = new Dictionary<string, string>();
            foreach (ProductFareTemp subProductFareTemp in ProductFareTempList)
            {
                ProductFareTempDic.Add(subProductFareTemp.Id.ToString(), subProductFareTemp.Name.ToString());
            }
            return ProductFareTempDic;
        }

        #endregion


        #region MerchantClass字典

        public Dictionary<string, string> getMerchantClassDic()
        {
            List<MerchantClass> MerchantClassList = db.MerchantClass.ToList();
            Dictionary<string, string> MerchantClassDic = new Dictionary<string, string>();
            foreach (MerchantClass subMerchantClass in MerchantClassList)
            {
                MerchantClassDic.Add(subMerchantClass.Id.ToString(), subMerchantClass.ColName.ToString());
            }
            return MerchantClassDic;
        }

        #endregion


        #region MerchantCol字典

        public Dictionary<string, string> getMerchantColDic()
        {
            List<MerchantCol> MerchantColList = db.MerchantCol.ToList();
            Dictionary<string, string> MerchantColDic = new Dictionary<string, string>();
            foreach (MerchantCol subMerchantCol in MerchantColList)
            {
                MerchantColDic.Add(subMerchantCol.ColId.ToString(), subMerchantCol.ColName.ToString());
            }
            return MerchantColDic;
        }

        #endregion


        #region MerchantInfo字典

        public Dictionary<string, string> getMerchantInfoDic()
        {
            List<MerchantInfo> MerchantInfoList = db.MerchantInfo.ToList();
            Dictionary<string, string> MerchantInfoDic = new Dictionary<string, string>();
            foreach (MerchantInfo subMerchantInfo in MerchantInfoList)
            {
                MerchantInfoDic.Add(subMerchantInfo.Id.ToString(), subMerchantInfo.Name.ToString());
            }
            return MerchantInfoDic;
        }

        #endregion


        #region ProfitObjectsActives字典

        public Dictionary<string, string> getProfitObjectsActivesDic()
        {
            List<ProfitObjectsActives> ProfitObjectsActivesList = db.ProfitObjectsActives.ToList();
            Dictionary<string, string> ProfitObjectsActivesDic = new Dictionary<string, string>();
            foreach (ProfitObjectsActives subProfitObjectsActives in ProfitObjectsActivesList)
            {
                ProfitObjectsActivesDic.Add(subProfitObjectsActives.Id.ToString(), subProfitObjectsActives.Name.ToString());
            }
            return ProfitObjectsActivesDic;
        }

        #endregion


        #region KqProductBrand字典

        public Dictionary<string, string> getKqProductBrandDic()
        {
            List<KqProducts> KqProductsList = db.KqProducts.ToList();
            Dictionary<string, string> KqProductsDic = new Dictionary<string, string>();
            foreach (KqProducts subKqProducts in KqProductsList)
            {
                KqProductsDic.Add(subKqProducts.Id.ToString(), subKqProducts.Name.ToString());
            }
            return KqProductsDic;
        }

        #endregion


        #region ChangeTypes字典

        public Dictionary<string, string> getChangeTypesDic()
        {
            List<ChangeTypes> ChangeTypesList = db.ChangeTypes.ToList();
            Dictionary<string, string> ChangeTypesDic = new Dictionary<string, string>();
            foreach (ChangeTypes subChangeTypes in ChangeTypesList)
            {
                ChangeTypesDic.Add(subChangeTypes.Id.ToString(), subChangeTypes.Name.ToString());
            }
            return ChangeTypesDic;
        }

        #endregion


        #region Users字典

        public Dictionary<string, string> getUsersDic()
        {
            List<Users> UsersList = db.Users.ToList();
            Dictionary<string, string> UsersDic = new Dictionary<string, string>();
            foreach (Users subUsers in UsersList)
            {
                UsersDic.Add(subUsers.Id.ToString(), subUsers.RealName.ToString());
            }
            return UsersDic;
        }

        #endregion


        #region StoreHouse字典

        public Dictionary<string, string> getStoreHouseDic()
        {
            List<StoreHouse> StoreHouseList = db.StoreHouse.ToList();
            Dictionary<string, string> StoreHouseDic = new Dictionary<string, string>();
            foreach (StoreHouse subStoreHouse in StoreHouseList)
            {
                StoreHouseDic.Add(subStoreHouse.Id.ToString(), subStoreHouse.StoreName.ToString());
            }
            return StoreHouseDic;
        }

        #endregion


        #region UserBackKind字典

        public Dictionary<string, string> getUserBackKindDic()
        {
            List<UserBackKind> UserBackKindList = db.UserBackKind.ToList();
            Dictionary<string, string> UserBackKindDic = new Dictionary<string, string>();
            foreach (UserBackKind subUserBackKind in UserBackKindList)
            {
                UserBackKindDic.Add(subUserBackKind.Id.ToString(), subUserBackKind.Name.ToString());
            }
            return UserBackKindDic;
        }

        #endregion


        #region UserLevelSet字典

        public Dictionary<string, string> getUserLevelSetDic()
        {
            List<UserLevelSet> UserLevelSetList = db.UserLevelSet.ToList();
            Dictionary<string, string> UserLevelSetDic = new Dictionary<string, string>();
            foreach (UserLevelSet subUserLevelSet in UserLevelSetList)
            {
                UserLevelSetDic.Add(subUserLevelSet.Id.ToString(), subUserLevelSet.Name.ToString());
            }
            return UserLevelSetDic;
        }

        #endregion

        #region Products字典

        public Dictionary<string, string> getProductsDic()
        {
            List<Products> ProductsList = db.Products.ToList();
            Dictionary<string, string> ProductsDic = new Dictionary<string, string>();
            foreach (Products subProducts in ProductsList)
            {
                ProductsDic.Add(subProducts.Id.ToString(), subProducts.ProductName.ToString());
            }
            return ProductsDic;
        }

        #endregion

        #region ErpCompanys字典

        public Dictionary<string, string> getErpCompanysDic()
        {
            List<ErpCompanys> ErpCompanysList = db.ErpCompanys.ToList();
            Dictionary<string, string> ErpCompanysDic = new Dictionary<string, string>();
            foreach (ErpCompanys subErpCompanys in ErpCompanysList)
            {
                ErpCompanysDic.Add(subErpCompanys.Name.ToString(), subErpCompanys.Name.ToString());
            }
            return ErpCompanysDic;
        }

        #endregion

        #region PosCoupons字典

        public Dictionary<string, string> getPosCouponsDic()
        {
            List<PosCoupons> PosCouponsList = db.PosCoupons.ToList();
            Dictionary<string, string> PosCouponsDic = new Dictionary<string, string>();
            foreach (PosCoupons subPosCoupons in PosCouponsList)
            {
                PosCouponsDic.Add(subPosCoupons.Id.ToString(), subPosCoupons.ExchangeCode.ToString());
            }
            return PosCouponsDic;
        }

        #endregion

        #region 银行信息字典

        public Dictionary<string, string> getBanksDic()
        {
            List<BankInfo> BankInfoList = db.BankInfo.ToList();
            Dictionary<string, string> BankInfoDic = new Dictionary<string, string>();
            foreach (BankInfo subBankInfo in BankInfoList)
            {
                BankInfoDic.Add(subBankInfo.BankCode, subBankInfo.BankName);
            }
            return BankInfoDic;
        }

        #endregion

        #region 顶级创客

        public Dictionary<string, string> getTopUserDic()
        {
            List<Users> TopUsers = db.Users.Where(m => m.ParentUserId == 0).OrderBy(m => m.Id).ToList();
            Dictionary<string, string> KqProductsDic = new Dictionary<string, string>();
            foreach (Users TopUser in TopUsers)
            {
                KqProductsDic.Add(TopUser.Id.ToString(), Library.function.CheckNull(TopUser.RealName).ToString());
            }
            return KqProductsDic;
        }

        #endregion



        #region Col字典

        public Dictionary<string, string> getColDic(string ColId = "")
        {
            List<BsModels.Col> ColList = bsdb.Col.Where(m => m.ColId.StartsWith(ColId)).OrderBy(m => m.ColId).ToList();
            Dictionary<string, string> ColDic = new Dictionary<string, string>();
            foreach (BsModels.Col subCol in ColList)
            {
                ColDic.Add(subCol.ColId.ToString(), subCol.ColName.ToString());
            }
            return ColDic;
        }

        public Dictionary<int, string> getColDicForInt(string ColId = "")
        {
            List<BsModels.Col> ColList = bsdb.Col.Where(m => m.ColId.StartsWith(ColId)).OrderBy(m => m.ColId).ToList();
            Dictionary<int, string> ColDic = new Dictionary<int, string>();
            foreach (BsModels.Col subCol in ColList)
            {
                ColDic.Add(subCol.Id, subCol.ColName.ToString());
            }
            return ColDic;
        }

        #endregion

        #region 角色字典

        public Dictionary<string, string> getRoleDic()
        {
            List<BsModels.SysAdminRole> List = bsdb.SysAdminRole.ToList();
            Dictionary<string, string> ColDic = new Dictionary<string, string>();
            foreach (BsModels.SysAdminRole sub in List)
            {
                ColDic.Add(sub.Id.ToString(), sub.Name.ToString());
            }
            return ColDic;
        }

        #endregion

        #region 后台管理员角色字典

        public Dictionary<string, string> getSysAdminRoleDic()
        {
            List<BsModels.SysAdminRole> SysAdminRoleList = bsdb.SysAdminRole.ToList();
            Dictionary<string, string> SysAdminRoleDic = new Dictionary<string, string>();
            foreach (BsModels.SysAdminRole subSysAdminRole in SysAdminRoleList)
            {
                SysAdminRoleDic.Add(subSysAdminRole.Id.ToString(), subSysAdminRole.Name.ToString());
            }
            return SysAdminRoleDic;
        }

        #endregion

        #region 后台管理员字典

        public Dictionary<string, string> getSysAdminDic()
        {
            List<SysAdmin> SysAdminList = db.SysAdmin.ToList();
            Dictionary<string, string> SysAdminDic = new Dictionary<string, string>();
            foreach (SysAdmin subSysAdmin in SysAdminList)
            {
                SysAdminDic.Add(subSysAdmin.Id.ToString(), subSysAdmin.AdminName.ToString());
            }
            return SysAdminDic;
        }

        #endregion

        #region 新后台管理员角色字典

        public Dictionary<string, string> getSysAdminRoleNewDic()
        {
            List<BsModels.SysAdminRoleNew> SysAdminRoleList = bsdb.SysAdminRoleNew.ToList();
            Dictionary<string, string> SysAdminRoleDic = new Dictionary<string, string>();
            foreach (BsModels.SysAdminRoleNew subSysAdminRole in SysAdminRoleList)
            {
                SysAdminRoleDic.Add(subSysAdminRole.Id.ToString(), subSysAdminRole.Name.ToString());
            }
            return SysAdminRoleDic;
        }

        #endregion

        #region 新后台管理员字典

        public Dictionary<string, string> getSysAdminNewDic()
        {
            List<BsModels.SysAdminNew> SysAdminList = bsdb.SysAdminNew.ToList();
            Dictionary<string, string> SysAdminDic = new Dictionary<string, string>();
            foreach (BsModels.SysAdminNew subSysAdmin in SysAdminList)
            {
                SysAdminDic.Add(subSysAdmin.Id.ToString(), subSysAdmin.AdminName.ToString());
            }
            return SysAdminDic;
        }

        #endregion

        #region SmallStoreHouse字典

        public Dictionary<string, string> getSmallStoreHouseDic()
        {
            List<SmallStoreHouse> SmallStoreHouseList = db.SmallStoreHouse.ToList();
            Dictionary<string, string> SmallStoreHouseDic = new Dictionary<string, string>();
            foreach (SmallStoreHouse subSmallStoreHouse in SmallStoreHouseList)
            {
                SmallStoreHouseDic.Add(subSmallStoreHouse.Id.ToString(), subSmallStoreHouse.StoreName.ToString());
            }
            return SmallStoreHouseDic;
        }

        #endregion


        #region KqProducts字典

        public Dictionary<string, string> getKqProductsDic()
        {
            List<KqProducts> KqProductsList = db.KqProducts.ToList();
            Dictionary<string, string> KqProductsDic = new Dictionary<string, string>();
            foreach (KqProducts subKqProducts in KqProductsList)
            {
                KqProductsDic.Add(subKqProducts.Id.ToString(), subKqProducts.Name.ToString());
            }
            return KqProductsDic;
        }

        #endregion

        #region PosMachinesTwo字典

        public Dictionary<string, string> getPosMachinesTwoDic()
        {
            List<PosMachinesTwo> PosMachinesTwoList = db.PosMachinesTwo.ToList();
            Dictionary<string, string> PosMachinesTwoDic = new Dictionary<string, string>();
            foreach (PosMachinesTwo subPosMachinesTwo in PosMachinesTwoList)
            {
                PosMachinesTwoDic.Add(subPosMachinesTwo.Id.ToString(), subPosMachinesTwo.PosSn.ToString());
            }
            return PosMachinesTwoDic;
        }

        #endregion



        #region 根据字典key获取字典值

        public string getDictionaryNameByKey(Dictionary<string, string> data, string key)
        {
            if (data.ContainsKey(key))
            {
                return data[key];
            }
            return "";
        }
        public string getDictionaryNameById(Dictionary<int, string> data, int key)
        {
            if (data.ContainsKey(key))
            {
                return data[key];
            }
            return "";
        }
        public string getDictionaryNamesByKeys(Dictionary<string, string> data, string keys)
        {
            string result = "";
            string[] keylist = keys.Split(',');
            foreach (string subkey in keylist)
            {
                if (data.ContainsKey(subkey))
                {
                    result += data[subkey] + ",";
                }
            }
            return result.TrimEnd(',');
        }

        #endregion


        #region SchoolSignInTask字典

        public Dictionary<string, string> getSchoolSignInTaskDic()
        {
            List<SchoolSignInTask> SchoolSignInTaskList = db.SchoolSignInTask.ToList();
            Dictionary<string, string> SchoolSignInTaskDic = new Dictionary<string, string>();
            foreach (SchoolSignInTask subSchoolSignInTask in SchoolSignInTaskList)
            {
                SchoolSignInTaskDic.Add(subSchoolSignInTask.Id.ToString(), subSchoolSignInTask.TaskName.ToString());
            }
            return SchoolSignInTaskDic;
        }

        #endregion
    }
}