示例#1
0
        /// <summary>
        /// Returns all pending EmailChangeVerifications in agencies where the Admin is approver.
        /// </summary>
        /// <param name="AgencyAdminUserId"></param>
        /// <returns></returns>

        private static IEnumerable <UserSummaryViewData> GetPendingEmailChangeVerificationsForAgencyAdmin(int AgencyAdminUserId, string scope)
        {
            IEnumerable <UserRegionalAccessProfile> profiles = UserAgencyBLL.GetUserAgencyProfiles(AgencyAdminUserId, 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(GetPendingEmailChangeVerificationsByAgencyId(profiles.First().RegionId, scope));
            }
            else
            {
                List <UserSummaryViewData>        userSummaryList = new List <UserSummaryViewData>();
                IEnumerable <UserSummaryViewData> tempList        = null;
                foreach (UserRegionalAccessProfile profile in profiles)
                {
                    tempList = GetPendingEmailChangeVerificationsByAgencyId(profiles.First().RegionId, scope);
                    if (tempList != null)
                    {
                        userSummaryList.AddRange(tempList);
                    }
                }
                return(userSummaryList);
            }
        }
示例#2
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);
        }
示例#3
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);
        }
示例#4
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);
        }