Example #1
0
        //Deals with access to an agency location or forms in an agency.
        #region "Grant/Revoke Operations"

        public static bool GrantAgencyAccessToUser(UserRegionalAccessProfile AgencyRegionProfile, int GrantedBy)
        {
            bool result = false;

            Database db = DatabaseFactory.CreateDatabase("DB_SHIP-NPR");

            using (DbCommand dbCmd = db.GetStoredProcCommand(StoredProcNames.UserAccess.GrantAgencyAccessToUser.Description()))
            {
                db.AddInParameter(dbCmd, "@UserId", DbType.Int32, AgencyRegionProfile.UserId);
                db.AddInParameter(dbCmd, "@AgencyId", DbType.Int32, AgencyRegionProfile.RegionId);
                db.AddInParameter(dbCmd, "@IsAdmin", DbType.Boolean, AgencyRegionProfile.IsAdmin);
                db.AddInParameter(dbCmd, "@IsDefaultAgency", DbType.Boolean, AgencyRegionProfile.IsDefaultRegion);
                db.AddInParameter(dbCmd, "@GrantedBy", DbType.Int32, GrantedBy);
                db.AddInParameter(dbCmd, "@IsApproverDesignate", DbType.Boolean, AgencyRegionProfile.IsApproverDesignate);
                db.AddInParameter(dbCmd, "@IsSuperDataEditor", DbType.Boolean, AgencyRegionProfile.IsSuperDataEditor);

                db.AddOutParameter(dbCmd, "@UserAgencyID", DbType.Int32, 4);

                if (db.ExecuteNonQuery(dbCmd) > 0)
                {
                    result = true;
                }
            }

            return(result);
        }
        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.";
            }
        }
Example #3
0
        protected void dataSourceSubStateUserEdit_Updated(object sender, ObjectContainerDataSourceStatusEventArgs e)
        {
            UserRegionalAccessProfile ChangedUserSubStateRegionData = (UserRegionalAccessProfile)e.Instance;

            if (UserSubStateRegionBLL.UpdateUserSubState(ChangedUserSubStateRegionData, this.AccountInfo.UserId))
            {
                bool ReviewerUpdateFailed = false;

                //Save the new ReviewerID (Supervisor)
                if (NewSupervisorId != UserIdOfOldReviewer)
                {
                    ReviewerUpdateFailed = !UserBLL.SaveSupervisorForUser(UserSubStateRegionData.UserId, NewSupervisorId, UserSubStateRegionId, this.AccountInfo.UserId);
                }


                if (ReviewerUpdateFailed)
                {
                    DisplayMessage("The new supervisor was not saved. The rest of the submitted information has been saved successfully.", false);
                }
                else
                {
                    DisplayMessage("The submitted information has been saved successfully.", false);
                }
            }
            else
            {
                DisplayMessage("Sorry. We were unable to save the information. Please contact support for assistance.", true);
            }

            UserData = null;
        }
Example #4
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.";
        }
Example #5
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);
            }
            //}
        }
        public static bool AddUserSubStateRegionalProfile(UserRegionalAccessProfile UserSubStateRegionProfile, int CreatedBy)
        {
            //using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
            //{
            //Save the Descriptors for User and then Approve.
            string ErrorMessage;

            if (GrantSubStateRegionAccessToUser(UserSubStateRegionProfile, CreatedBy))
            {
                if (UserSubStateRegionProfile.DescriptorIDList != null && UserSubStateRegionProfile.DescriptorIDList.Count > 0)
                {
                    int UserId = UserSubStateRegionProfile.UserId;
                    IEnumerable <int> NewDescriptorIds = UserSubStateRegionProfile.DescriptorIDList;
                    int AgencyId = UserSubStateRegionProfile.RegionId;

                    if (!UserBLL.SaveDescriptors(UserId, NewDescriptorIds, AgencyId, CreatedBy, out ErrorMessage))
                    {
                        return(false);
                    }
                }

                //scope.Complete();
                return(true);
            }
            else
            {
                return(false);
            }
            //}
        }
Example #7
0
        protected void dataSourceSubStateUserAdd_Updated(object sender, ObjectContainerDataSourceStatusEventArgs e)
        {
            UserRegionalAccessProfile ChangedUserSubStateRegionData = (UserRegionalAccessProfile)e.Instance;

            UpdateUserSubStateRegionData(ChangedUserSubStateRegionData);

            if (UserSubStateRegionData.RegionId != 0)
            {
                if (UserSubStateRegionBLL.AddUserSubStateRegionalProfile(UserSubStateRegionData, this.AccountInfo.UserId))
                {
                    //display success message
                    DisplayMessage("The submitted information has been saved successfully.", false);
                }
                else
                {
                    DisplayMessage("Sorry. We were unable to save the information. Please contact support for assistance.", true);
                }
            }
            else
            {
                plhMessage.Visible   = true;
                lblTitleMessage.Text = "Error";
                lblMessage.Text      = "A Sub state must be selected.";
                lblMessage.CssClass  = "required";

                hlBackToEdit.EnableViewState = false;
                hlBackToEdit.Visible         = false;
                hlBackToEdit.NavigateUrl     = RouteController.UserEdit(UserProfileUserId);
            }

            Page.DataBind();
        }
 private void SynchronizeChangesToUserAgencyData(UserRegionalAccessProfile ChangedUserAgencyData)
 {
     UserAgencyData.DescriptorIDList    = ChangedUserAgencyData.DescriptorIDList;
     UserAgencyData.IsActive            = ChangedUserAgencyData.IsActive;
     UserAgencyData.IsAdmin             = ChangedUserAgencyData.IsAdmin;
     UserAgencyData.IsApproverDesignate = ChangedUserAgencyData.IsApproverDesignate;
     UserAgencyData.IsDefaultRegion     = ChangedUserAgencyData.IsDefaultRegion;
     UserAgencyData.IsSuperDataEditor   = ChangedUserAgencyData.IsSuperDataEditor;
 }
Example #9
0
        private void InitializeData()
        {
            PopulateParamsFromRouteData();
            FetchData();

            //Set base for UserSubStateRegionData which will be manually populated by User
            UserSubStateRegionData        = new UserRegionalAccessProfile();
            UserSubStateRegionData.UserId = UserData.UserId;
        }
Example #10
0
 private void UpdateUserSubStateRegionData(UserRegionalAccessProfile ChangedProfile)
 {
     UserSubStateRegionData.RegionId            = ChangedProfile.RegionId;
     UserSubStateRegionData.DescriptorIDList    = ChangedProfile.DescriptorIDList;
     UserSubStateRegionData.IsAdmin             = ChangedProfile.IsAdmin;
     UserSubStateRegionData.IsDefaultRegion     = ChangedProfile.IsDefaultRegion;
     UserSubStateRegionData.IsApproverDesignate = ChangedProfile.IsApproverDesignate;
     UserSubStateRegionData.IsSuperDataEditor   = ChangedProfile.IsSuperDataEditor;
 }
Example #11
0
        //Add Delete Operations - Deals with adding/deleting User's agency level attributes.
        #region "Add/Delete Operations"
        /// <summary>
        /// Adds one descriptor to a User in an Agency.
        /// </summary>
        /// <param name="UserDescriptorObj">UserDescriptor</param>
        /// <param name="AddedBy">int</param>
        /// <param name="UserDescriptorId">out int</param>
        /// <returns>bool</returns>
        ////public static bool AddDescriptorForUser(UserDescriptor UserDescriptorObj, int AddedBy, out int UserDescriptorId) {

        ////    bool result = false;

        ////    Database db = DatabaseFactory.CreateDatabase("DB_SHIP-NPR");
        ////    int userDescriptorIdOut = -1;

        ////    using (DbCommand dbCmd = db.GetStoredProcCommand(StoredProcNames.UserAgency.AddDescriptorsForUser.Description()))
        ////    {
        ////        db.AddInParameter(dbCmd, "@UserID", DbType.Int32, UserDescriptorObj.UserId);
        ////        db.AddInParameter(dbCmd, "@DescriptorID", DbType.Int32, UserDescriptorObj.DescriptorId);
        ////        db.AddInParameter(dbCmd, "@AgencyID", DbType.Int32, UserDescriptorObj.AgencyId);
        ////        db.AddInParameter(dbCmd, "@CreatedBy", DbType.Int32, AddedBy);
        ////        db.AddOutParameter(dbCmd, "@UserDescriptorID", DbType.Int32, 4);

        ////        db.ExecuteNonQuery(dbCmd);

        ////        if (dbCmd.Parameters["@UserDescriptorID"].Value != null)
        ////        {
        ////            userDescriptorIdOut = (int)dbCmd.Parameters["@UserDescriptorID"].Value;
        ////            result = true;
        ////        }
        ////    }

        ////    UserDescriptorId = userDescriptorIdOut;
        ////    return result;
        ////}



        /// <summary>
        /// Add a reviewer for an AgencyUser.
        /// For multiple descriptors Or multiple agencies, this method must be called multiple times.
        /// </summary>
        /// <param name="userReviewerObj">UserReviewer</param>
        /// <param name="outUserReviewerId">out int</param>
        /// <returns>bool</returns>
        //public static bool AddReviewerForUser(UserReviewer userReviewerObj, out int outUserReviewerId)
        //{
        //    bool result = false;

        //    Database db = DatabaseFactory.CreateDatabase("DB_SHIP-NPR");
        //    int userReviewerIdOut = -1;

        //    using (DbCommand dbCmd = db.GetStoredProcCommand(StoredProcNames.UserAgency.AddReviewerForUser.Description()))
        //    {
        //        db.AddInParameter(dbCmd, "@UserAgencyID", DbType.Int32, userReviewerObj.UserAgencyId );
        //        db.AddInParameter(dbCmd, "@ReviewerID", DbType.Int32, userReviewerObj.ReviewerId);
        //        db.AddInParameter(dbCmd, "@FormID", DbType.Int16, userReviewerObj.FormId);
        //        db.AddInParameter(dbCmd, "@ActionID", DbType.Int16, userReviewerObj.ActionId);
        //        db.AddInParameter(dbCmd, "@CreatedBy", DbType.Int32, userReviewerObj.CreatedBy);

        //        db.AddOutParameter(dbCmd, "@UserReviewerID", DbType.Int32, 4);

        //        dbCmd.ExecuteNonQuery();

        //        if (dbCmd.Parameters["@UserReviewerID"].Value != null)
        //        {
        //            userReviewerIdOut = (int)dbCmd.Parameters["@UserReviewerID"].Value;
        //            result = true;
        //        }
        //    }
        //    outUserReviewerId = userReviewerIdOut;
        //    return result;
        //}


        /// <summary>
        /// Update a User's account in a Sub State Region.
        /// </summary>
        /// <param name="userAcctObj">UserRegionalAccessProfile</param>
        /// <param name="UpdatedBy">int</param>
        /// <returns>bool</returns>
        public static bool UpdateUserAgency(UserRegionalAccessProfile UserRegionalProfile, int UpdatedBy)
        {
            Database db = DatabaseFactory.CreateDatabase("DB_SHIP-NPR");

            using (DbCommand dbCmd = db.GetStoredProcCommand(StoredProcNames.UserAgency.UpdateUserAgency.Description()))
            {
                db.AddInParameter(dbCmd, "@UserAgencyId", DbType.Int32, UserRegionalProfile.Id);
                db.AddInParameter(dbCmd, "@IsAdmin", DbType.Boolean, UserRegionalProfile.IsAdmin);
                db.AddInParameter(dbCmd, "@IsDefaultAgency", DbType.Boolean, UserRegionalProfile.IsDefaultRegion);
                db.AddInParameter(dbCmd, "@IsActive", DbType.Boolean, UserRegionalProfile.IsActive);
                db.AddInParameter(dbCmd, "@UpdatedBy", DbType.Int32, UpdatedBy);
                db.AddInParameter(dbCmd, "@IsApproverDesignate", DbType.Boolean, UserRegionalProfile.IsApproverDesignate);
                db.AddInParameter(dbCmd, "@IsSuperDataEditor", DbType.Boolean, UserRegionalProfile.IsSuperDataEditor);
                return(db.ExecuteNonQuery(dbCmd) > 0);
            }
        }
Example #12
0
        //public static bool GrantSubStateRegionAccessToUser(int UserId, int SubStateRegionId, bool IsAdmin, int GrantedBy)
        public static bool GrantSubStateRegionAccessToUser(UserRegionalAccessProfile SubStateProfile, int GrantedBy)
        {
            Database db = DatabaseFactory.CreateDatabase("DB_SHIP-NPR");

            using (DbCommand dbCmd = db.GetStoredProcCommand(StoredProcNames.UserAccess.GrantSubStateRegionAccessToUser.Description()))
            {
                db.AddInParameter(dbCmd, "@UserId", DbType.Int32, SubStateProfile.UserId);
                db.AddInParameter(dbCmd, "@SubStateRegionId", DbType.Int32, SubStateProfile.RegionId);
                db.AddInParameter(dbCmd, "@IsAdmin", DbType.Boolean, SubStateProfile.IsAdmin);
                db.AddInParameter(dbCmd, "@GrantedBy", DbType.Int32, GrantedBy);
                db.AddInParameter(dbCmd, "@IsApproverDesignate", DbType.Boolean, SubStateProfile.IsApproverDesignate);
                db.AddInParameter(dbCmd, "@IsSuperDataEditor", DbType.Boolean, SubStateProfile.IsSuperDataEditor);
                db.AddInParameter(dbCmd, "@IsDefaultSubStateRegion", DbType.Boolean, SubStateProfile.IsDefaultRegion);

                db.AddOutParameter(dbCmd, "@UserSubStateRegionID", DbType.Int32, 4);

                return(db.ExecuteNonQuery(dbCmd) > 0);
            }
        }
Example #13
0
        protected bool IsEditAccessAllowed(int RegionId)
        {
            bool IsAllowed = false;

            //return AccessRulesBLL.CanEditUserProfile(this.userProfileViewData, UserBLL.GetUser(this.AccountInfo.UserId));
            if (userProfileViewData.IsUserSubStateRegionalScope)
            {
                UserRegionalAccessProfile subStateProfile = userProfileViewData.RegionalProfiles.Where(p => p.RegionId == RegionId).FirstOrDefault();
                if (subStateProfile != null)
                {
                    IsAllowed = AccessRulesBLL.CanEditSubStateUser(subStateProfile.RegionId,
                                                                   subStateProfile.IsAdmin,
                                                                   userProfileViewData.StateFIPS,
                                                                   subStateProfile.IsApproverDesignate,
                                                                   AdminViewData);
                }
            }
            else if (userProfileViewData.IsUserAgencyScope)
            {
                UserRegionalAccessProfile AgencyProfile = userProfileViewData.RegionalProfiles.Where(p => p.RegionId == RegionId).FirstOrDefault();
                if (AgencyProfile != null)
                {
                    IsAllowed = AccessRulesBLL.CanEditAgencyUser(AgencyProfile.RegionId,
                                                                 AgencyProfile.IsAdmin,
                                                                 userProfileViewData.StateFIPS,
                                                                 AgencyProfile.IsApproverDesignate,
                                                                 AdminViewData);
                }
            }
            else if (userProfileViewData.IsUserCMSRegionalScope)
            {
                UserRegionalAccessProfile CMSRegionalProfile = userProfileViewData.RegionalProfiles.Where(p => p.RegionId == RegionId).FirstOrDefault();
                if (CMSRegionalProfile != null)
                {
                    IsAllowed = AccessRulesBLL.CanEditUserProfile(userProfileViewData, AdminViewData);
                }
            }

            return(IsAllowed);
        }
Example #14
0
 //Deals with access to an CMS level access
 #region "Grant/Revoke Operations"
 //public static bool GrantSubStateRegionAccessToUser(int UserId, int SubStateRegionId, bool IsAdmin, int GrantedById)
 public static bool GrantSubStateRegionAccessToUser(UserRegionalAccessProfile UserSubStateProfile, int GrantedById)
 {
     return(UserSubStateRegionDAL.GrantSubStateRegionAccessToUser(UserSubStateProfile, GrantedById));
 }