示例#1
0
        private void HandleSubStateDisplayLogic(string StateFIPS)
        {
            plhSubStateRegion.Visible = true;
            if (this.AccountInfo.Scope != Scope.SubStateRegion)
            {
                var SubStates = LookupBLL.GetSubStateRegionsForState(StateFIPS);
                if (SubStates != null)
                {
                    IEnumerable <KeyValuePair <int, string> > OrderedSubStates = SubStates.OrderBy(p => p.Value);
                    ddlSubStateRegion.DataSource = OrderedSubStates;
                }
                else
                {
                    ddlSubStateRegion.DataSource = SubStates;
                }

                ddlSubStateRegion.DataTextField  = "Value";
                ddlSubStateRegion.DataValueField = "Key";
                ddlSubStateRegion.DataBind();

                if (ddlSubStateRegion.Items.Count > 1)
                {
                    ddlSubStateRegion.Items.Insert(0, new ListItem("Select Sub State Region", "0"));
                }
                else
                {
                    ddlSubStateRegion.Items.Add(new ListItem("No Sub State Regions available", "0"));
                }
            }
            else
            {
                PopulateSubStateRegionsForUser();
            }
        }
示例#2
0
 private void HandleSubStateDisplayLogic(string StateFIPS)
 {
     plhSubStateRegion.Visible        = true;
     ddlSubStateRegion.DataSource     = LookupBLL.GetSubStateRegionsForState(StateFIPS);
     ddlSubStateRegion.DataTextField  = "Value";
     ddlSubStateRegion.DataValueField = "Key";
     ddlSubStateRegion.DataBind();
     ddlSubStateRegion.Items.Insert(0, new ListItem("Select a Sub State Region", "0"));
 }
示例#3
0
        protected void PopulateSubStateList()
        {
            List <KeyValuePair <int, string> > SubStatesListObj = new List <KeyValuePair <int, string> >();

            //Get all Sub States where User is Admin.
            IEnumerable <UserRegionalAccessProfile> SubStatesWhereUserIsAdmin = null;
            IDictionary <int, string> AllSubStatesInState = LookupBLL.GetSubStateRegionsForState(UserData.StateFIPS);

            //If the Admin is a User of Sub State Scope, we need only those sub states
            if (IsCreatorSubStateScope)
            {
                SubStatesWhereUserIsAdmin = UserSubStateRegionBLL.GetUserSubStateRegionalProfiles(this.AccountInfo.UserId, true);

                KeyValuePair <int, string>?matchingSubState = null;
                foreach (UserRegionalAccessProfile SubStateAdminProfile in SubStatesWhereUserIsAdmin)
                {
                    matchingSubState = AllSubStatesInState.Where(p => p.Key == SubStateAdminProfile.RegionId).FirstOrDefault();
                    if (matchingSubState.HasValue)
                    {
                        SubStatesListObj.Add(matchingSubState.Value);
                        matchingSubState = null;
                    }
                }
            }
            //else, lets use all sub states in the User's state.
            //Since a sub state user can only be created by user of sub state or higher scope, current
            //user can add this new user to any sub state in the state.
            else
            {
                SubStatesListObj = AllSubStatesInState.ToList <KeyValuePair <int, string> >();
            }

            //Before we return the list of sub states we need to remove the substates that the User is already assigned to,
            //so that the user is not added to the same sub state again.
            if (SubStatesListObj != null && SubStatesListObj.Count > 0)
            {
                IEnumerable <UserRegionalAccessProfile> ExistingSubStates = null;
                ExistingSubStates = UserSubStateRegionBLL.GetUserSubStateRegionalProfiles(UserProfileUserId, false);

                if (ExistingSubStates != null && ExistingSubStates.Count() > 0)
                {
                    KeyValuePair <int, string>?existSubState = null;
                    foreach (UserRegionalAccessProfile ExistingSubState in ExistingSubStates)
                    {
                        existSubState = SubStatesListObj.Where(p => p.Key == ExistingSubState.RegionId).FirstOrDefault();
                        if (existSubState.HasValue)
                        {
                            SubStatesListObj.Remove(existSubState.Value);
                            existSubState = null;
                        }
                    }
                }
            }

            this.SubStateList = SubStatesListObj;
        }
示例#4
0
        private void HandleSubStateDisplayLogic(string StateFIPS)
        {
            plhSubStateRegion.Visible = true;
            if (this.AccountInfo.Scope != Scope.SubStateRegion)
            {
                ddlSubStateRegion.DataSource     = LookupBLL.GetSubStateRegionsForState(StateFIPS);
                ddlSubStateRegion.DataTextField  = "Value";
                ddlSubStateRegion.DataValueField = "Key";
                ddlSubStateRegion.DataBind();
            }
            else
            {
                PopulateSubStateRegionsForUser();
            }

            if (ddlSubStateRegion.Items.Count > 1)
            {
                ddlSubStateRegion.Items.Insert(0, new ListItem("Select Sub State Region", "0"));
            }
        }