Exemple #1
0
        /// <summary>
        /// Returns all pending EmailChangeVerifications where the Admin is an Approver designate.
        /// </summary>
        /// <param name="UserId"></param>
        /// <returns></returns>
        private static IEnumerable <UserSummaryViewData> GetPendingEmailChangeVerificationsForSubStateAdmin(int SubStateAdminUserId, string scope)
        {
            IEnumerable <UserRegionalAccessProfile> profiles = UserSubStateRegionBLL.GetUserSubStateRegionalProfiles(SubStateAdminUserId, true).Where(p => p.IsApproverDesignate == true);
            int Count = 0;

            if (profiles != null)
            {
                Count = profiles.Count();
            }

            if (Count == 0)
            {
                return(null);
            }
            else if (Count == 1)
            {
                return(GetPendingEmailChangeVerificationsBySubStateRegionId(profiles.First().RegionId, scope));
            }
            else
            {
                List <UserSummaryViewData>        userSummaryList = new List <UserSummaryViewData>();
                IEnumerable <UserSummaryViewData> tempList        = null;
                foreach (UserRegionalAccessProfile profile in profiles)
                {
                    tempList = GetPendingEmailChangeVerificationsBySubStateRegionId(profiles.First().RegionId, scope);
                    if (tempList != null)
                    {
                        userSummaryList.AddRange(tempList);
                    }
                }
                return(userSummaryList);
            }
        }
        protected override void GrantAccessToRegion()
        {
            //TODO: Need to refactor in future. Just use the UserRegionalAccessProfile object of UserRegistrationData
            UserRegionalAccessProfile UserSubStateProfile = new UserRegionalAccessProfile();

            UserSubStateProfile.UserId          = UserId.Value;
            UserSubStateProfile.RegionId        = this.SubStateRegionId;
            UserSubStateProfile.IsAdmin         = UserRegistrationData.RoleRequested.IsAdmin;
            UserSubStateProfile.IsDefaultRegion = true;

            int GrantedBy = 0;

            if (UserRegistrationData.IsRegistrationRequest)
            {
                GrantedBy = UserId.Value;
                UserSubStateProfile.IsApproverDesignate = false;
            }
            else
            {
                GrantedBy = UserRegistrationData.RegisteredByUserId.Value;
                UserSubStateProfile.IsApproverDesignate = UserRegistrationData.UserRegionalAccessProfile.IsApproverDesignate;
            }

            //if (!UserSubStateRegionBLL.GrantSubStateRegionAccessToUser(UserId.Value, this.SubStateRegionId, UserRegistrationData.RoleRequested.IsAdmin, UserId.Value))
            if (!UserSubStateRegionBLL.GrantSubStateRegionAccessToUser(UserSubStateProfile, GrantedBy))
            {
                this.ErrorMessage = "Sorry. We encountered an error while saving the Sub State Region information.";
            }
        }
Exemple #3
0
        /// <summary>
        /// Can Approve Sub State User if:
        /// #) CMS Approvers
        /// #) Same State Ship Director
        /// #) Same State Approver Designate
        /// #) Same Sub State Approver Designates
        /// </summary>
        /// <param name="AccountInfo"></param>
        /// <param name="SubStateRegionId"></param>
        /// <returns></returns>
        public static bool IsApproverForSubState(UserAccount AccountInfo, int SubStateRegionId)
        {
            bool IsApprover = false;

            if (AccountInfo.Scope.IsEqual(Scope.CMS))
            {
                return(IsApproverAtCMS(AccountInfo));
            }
            else if (AccountInfo.Scope.IsEqual(Scope.State))
            {
                var SubStates = LookupBLL.GetSubStateRegionsForState(AccountInfo.StateFIPS);
                if (SubStates != null && SubStates.Count > 0)
                {
                    //Check if Sub State is part of Admin State [Same State check]
                    if (SubStates.Keys.Contains(SubStateRegionId))
                    {
                        return(IsApproverForState(AccountInfo, AccountInfo.StateFIPS));
                    }
                }
            }
            else if (AccountInfo.Scope.IsEqual(Scope.SubStateRegion))    //for clarity
            {
                var SubStateAdminProfiles = UserSubStateRegionBLL.GetUserSubStateRegionalProfiles(AccountInfo.UserId, true);
                foreach (UserRegionalAccessProfile SubStateProfile in SubStateAdminProfiles)
                {
                    //Is admin is already checked while retrieving SubState profiles. Added for clarity.
                    if (SubStateProfile.RegionId == SubStateRegionId)
                    {
                        return(SubStateProfile.IsAdmin && SubStateProfile.IsApproverDesignate);
                    }
                }
            }
            return(IsApprover);
        }
Exemple #4
0
        /// <summary>
        /// If a specific agency or sub state or state is unknown, use role to find if approver at a higher role irrelevant of specific region.
        /// </summary>
        /// <returns></returns>
        public static bool IsApproverForRole(UserAccount AdminAccountInfo, Role RoleToCheck)
        {
            //If requested role is CMS/CMSRegional Scope, Admin must be CMS Admin
            if (RoleToCheck.scope.IsHigherOrEqualTo(Scope.CMSRegional))
            {
                return(IsApproverAtCMS(AdminAccountInfo));
            }
            //If requested role is State Scope, Admin must be approver at State or CMS Level
            if (RoleToCheck.scope.IsEqual(Scope.State))
            {
                return(IsApproverForState(AdminAccountInfo, AdminAccountInfo.StateFIPS));
            }
            //If requested role is SubState, Admin must be State level approver.
            //Since SubState Admins cannot create other Admins, Can Approve show/hide question does not arise.
            if (RoleToCheck.scope.IsEqual(Scope.SubStateRegion))
            {
                if (AdminAccountInfo.Scope.IsHigherOrEqualTo(Scope.State))
                {
                    return(IsApproverForState(AdminAccountInfo, AdminAccountInfo.StateFIPS));
                }
                else if (AdminAccountInfo.Scope.IsEqual(Scope.SubStateRegion))
                {
                    //[Approver]Approvers at Sub States can approve Sub State Admins/Users.
                    var SubStateProfiles = UserSubStateRegionBLL.GetUserSubStateRegionalProfiles(AdminAccountInfo.UserId, true).Where(p => p.IsApproverDesignate);
                    if (SubStateProfiles != null && SubStateProfiles.Count() > 0)
                    {
                        return(true);
                    }
                }
                return(false);
            }
            if (RoleToCheck.scope.IsEqual(Scope.Agency))
            {
                if (AdminAccountInfo.Scope.IsHigherOrEqualTo(Scope.State))
                {
                    return(IsApproverForState(AdminAccountInfo, AdminAccountInfo.StateFIPS));
                }
                else if (AdminAccountInfo.Scope.IsEqual(Scope.SubStateRegion))
                {
                    //Approvers for Sub States are approvers for agencies
                    var SubstateProfiles = UserSubStateRegionBLL.GetUserSubStateRegionalProfiles(AdminAccountInfo.UserId, true).Where(p => p.IsApproverDesignate == true);
                    if (SubstateProfiles != null && SubstateProfiles.Count() > 0)
                    {
                        return(true);
                    }
                }
                else if (AdminAccountInfo.Scope.IsEqual(Scope.Agency))
                {
                    //Approvers for Sub States are approvers for agencies
                    var agencyProfiles = UserAgencyBLL.GetUserAgencyProfiles(AdminAccountInfo.UserId, true).Where(p => p.IsApproverDesignate == true);
                    if (agencyProfiles != null && agencyProfiles.Count() > 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemple #5
0
        /// <summary>
        /// Can Approve Agency if Approver is one of the following:
        /// #) CMS Approvers
        /// #) Ship Director or State Approver
        /// #) Sub State Approver, where User Agency is part of Approver Sub State
        /// #) Same Agency Approver
        /// </summary>
        /// <param name="AccountInfo"></param>
        /// <param name="AgencyId"></param>
        /// <returns></returns>
        public static bool IsApproverForAgency(UserAccount AccountInfo, int AgencyId)
        {
            bool IsApprover = false;

            if (AccountInfo.Scope.IsEqual(Scope.CMS))
            {
                return(IsApproverAtCMS(AccountInfo));
            }
            else if (AccountInfo.Scope.IsEqual(Scope.State))
            {
                return(IsApproverForState(AccountInfo, AccountInfo.StateFIPS));
            }
            else if (AccountInfo.Scope.IsEqual(Scope.SubStateRegion))    //for clarity
            {
                var SubStateAdminProfiles = UserSubStateRegionBLL.GetUserSubStateRegionalProfiles(AccountInfo.UserId, true);
                foreach (UserRegionalAccessProfile SubStateProfile in SubStateAdminProfiles)
                {
                    var AgenciesForSubState = LookupBLL.GetAgenciesForSubStateRegion(SubStateProfile.RegionId);
                    if (AgenciesForSubState != null && AgenciesForSubState.Count() > 0)
                    {
                        foreach (Agency ag in AgenciesForSubState)
                        {
                            //If agency is part of the Admin Sub State
                            if (ag.Id == AgencyId)
                            {
                                //Is admin is already checked while retrieving SubState profiles. Added for clarity.
                                return(SubStateProfile.IsAdmin && SubStateProfile.IsApproverDesignate);
                            }
                        }
                    }
                }
            }
            else if (AccountInfo.Scope.IsEqual(Scope.Agency))
            {
                var AdminAgencies = UserAgencyBLL.GetUserAgencyProfiles(AccountInfo.UserId, true);
                foreach (UserRegionalAccessProfile agencyProfile in AdminAgencies)
                {
                    //Is admin is already checked while retrieving Agency profiles. Added for clarity.
                    if (agencyProfile.RegionId == AgencyId)
                    {
                        return(agencyProfile.IsAdmin && agencyProfile.IsApproverDesignate);
                    }
                }
            }

            return(IsApprover);
        }
Exemple #6
0
        /// <summary>
        /// Returns complete User profile of a User who is pending approval. The profile includes Account info, Personal profile and Regional profiles (agencies, sub state regions etc).
        /// </summary>
        /// <param name="UserId"></param>
        /// <returns></returns>
        //public static UserViewData GetPendingUser(int UserId)
        //{
        //    User userObj = new User();
        //    userObj.UserAccount = UserBLL.GetUserAccount(UserId);
        //    if (userObj.UserAccount != null)
        //    {
        //        userObj.UserProfile = UserBLL.GetUserProfile(UserId);

        //        if (userObj.UserAccount.Scope.CompareTo(Scope.Agency, ComparisonCriteria.IsEqual))
        //            userObj.UserRegionalProfiles = new List<UserRegionalAccessProfile>(UserAgencyBLL.GetUserAgencyProfiles(UserId, false));
        //        else if (userObj.UserAccount.Scope.CompareTo(Scope.SubStateRegion, ComparisonCriteria.IsEqual))
        //            userObj.UserRegionalProfiles = new List<UserRegionalAccessProfile>(UserSubStateRegionBLL.GetUserSubStateRegionalProfiles(UserId, false));
        //        else if (userObj.UserAccount.Scope.CompareTo(Scope.CMSRegional, ComparisonCriteria.IsEqual))
        //            userObj.UserRegionalProfiles = new List<UserRegionalAccessProfile>(UserCMSBLL.GetUserCMSRegionalProfiles(UserId, false));
        //    }
        //    else
        //        return null;

        //    UserViewData viewData = Mapper.Map<User, UserViewData>(userObj);

        //    StepUpViewData(ref viewData);
        //    return viewData;

        //}


        /// <summary>
        /// Returns complete User profile that includes Account info, Personal profile and Regional profiles (agencies, sub state regions etc).
        /// </summary>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public static UserViewData GetUser(int UserId)
        {
            User userObj = new User();

            userObj.UserAccount = UserBLL.GetUserAccount(UserId);
            if (userObj.UserAccount != null && (userObj.UserAccount.UserId > 0))
            {
                userObj.UserProfile = UserBLL.GetUserProfile(UserId);

                if (userObj.UserAccount.Scope.IsEqual(Scope.Agency))
                {
                    userObj.UserRegionalProfiles = new List <UserRegionalAccessProfile>(UserAgencyBLL.GetUserAgencyProfiles(UserId, false));
                }
                else if (userObj.UserAccount.Scope.IsEqual(Scope.SubStateRegion))
                {
                    userObj.UserRegionalProfiles = new List <UserRegionalAccessProfile>(UserSubStateRegionBLL.GetUserSubStateRegionalProfiles(UserId, false));
                }
                else if (userObj.UserAccount.Scope.IsEqual(Scope.CMSRegional))
                {
                    userObj.UserRegionalProfiles = new List <UserRegionalAccessProfile>(UserCMSBLL.GetUserCMSRegionalProfiles(UserId, false));
                }
                else
                {
                    userObj.UserRegionalProfiles = new List <UserRegionalAccessProfile>();
                }
            }
            else
            {
                return(null);
            }

            UserViewData viewData = Mapper.Map <User, UserViewData>(userObj);

            StepUpViewData(ref viewData);

            return(viewData);
        }