private int GetLevel(int level, ref string mkey, bool IsMBD) { Model.Member memberModel = (TModel == null ? BllModel.TModel : TModel); if (!memberModel.Role.Super) { if (mkey == memberModel.MID) { if (level > memberModel.MAgencyType.ViewLevel) { level = memberModel.MAgencyType.ViewLevel; } } else { int levelCount = BllModel.GetLevelForView(mkey, IsMBD); if (levelCount > 0) { if (level + levelCount > memberModel.MAgencyType.ViewLevel) { level = memberModel.MAgencyType.ViewLevel - levelCount > level ? level : memberModel.MAgencyType.ViewLevel - levelCount; } } else { mkey = memberModel.MID; } } } return(level); }