Exemple #1
0
        /// <summary>
        /// Update Agency profile for User
        /// </summary>
        /// <param name="UserSubStateRegionProfile"></param>
        /// <param name="UpdatedBy"></param>
        /// <returns></returns>
        public static bool UpdateUserAgency(UserRegionalAccessProfile UserAgencyProfile, int UpdatedBy)
        {
            //using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
            //{
            //Save the Descriptors for User and then Approve.
            IEnumerable <int> NewDescriptorIds = UserAgencyProfile.DescriptorIDList;
            int    UserId   = UserAgencyProfile.UserId;
            int    AgencyId = UserAgencyProfile.RegionId;
            string ErrorMessage;

            if (UserAgencyDAL.UpdateUserAgency(UserAgencyProfile, UpdatedBy))
            {
                if (UserBLL.SaveDescriptors(UserId, NewDescriptorIds, AgencyId, UpdatedBy, out ErrorMessage))
                {
                    //scope.Complete();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
            //}
        }
Exemple #2
0
        protected override void GrantAccessToRegion()
        {
            //TODO: Need to refactor in future. Just use the UserRegionalAccessProfile object of UserRegistrationData

            UserRegionalAccessProfile AgencyProfile = new UserRegionalAccessProfile();

            AgencyProfile.UserId          = UserId.Value;
            AgencyProfile.RegionId        = this.AgencyId;
            AgencyProfile.IsAdmin         = UserRegistrationData.RoleRequested.IsAdmin;
            AgencyProfile.IsDefaultRegion = true;       //First Agency set during registration is assumed default.

            int AccessGrantedBy = -1;

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

            if (!UserAgencyDAL.GrantAgencyAccessToUser(AgencyProfile, AccessGrantedBy))
            {
                this.ErrorMessage = "Sorry. We encountered an error while saving the agency information.";
            }

            //if (!UserAgencyDAL.GrantAgencyAccessToUser(UserId.Value, this.AgencyId, UserRegistrationData.RoleRequested.IsAdmin, true, UserId.Value))
            //    this.ErrorMessage = "Sorry. We encountered an error while saving the agency information.";
        }
Exemple #3
0
        //Get Operations
        #region "Gets"

        public static IEnumerable <UserRegionalAccessProfile> GetUserAgencyProfiles(int UserId, bool OnlyAdminProfiles)
        {
            if (OnlyAdminProfiles)
            {
                return(from profile in UserAgencyDAL.GetUserAgencyProfiles(UserId) where profile.IsAdmin == true select profile);
            }
            else
            {
                return(UserAgencyDAL.GetUserAgencyProfiles(UserId));
            }
        }