コード例 #1
0
        // <summary>
        ///
        /// Getting a sspecific user data py passing his/her name
        /// as a parameter
        ///
        /// Added 4/15/2016 By Ibarahim Abuzaid
        /// </summary>
        public List <UserRole> GetUserRoleListByUser(int userID)
        {
            /// <summary>
            /// Author: Ibrahim Abuzaid
            /// Data Transfer Object to represent a User from the
            /// Database
            ///
            /// Added 3/25 By Ibarahim
            /// </summary>
            try
            {
                var userRoleList = UserRoleAccessor.RetrieveUserRoleListByUser(userID);

                if (userRoleList.Count > 0)
                {
                    return(userRoleList);
                }
                else
                {
                    throw new ApplicationException("There were no records found.");
                }
            }

            catch (Exception)
            {
                // *** we should sort the possible exceptions and return friendly messages for each
                Console.Out.WriteLine("Exception Handler on Role manager Class...");
                throw;
            }
        }
コード例 #2
0
 public int GetUserRoleCount()
 {
     try
     {
         return(UserRoleAccessor.RetrieveUserRoleCount());
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #3
0
        public bool EditUserRoleStatus(int usr, string role, bool active)
        {
            if (usr < 1000)
            {
                throw new ApplicationException("Invalid userID");
            }

            try
            {
                if (UserRoleAccessor.UpdateUserRoleStatus(usr, role, active) == 1)
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(false);
        }
コード例 #4
0
        // should be replaced by EditUserRoleStatus
        public bool RemoveUserRole(int usr, string role)
        {
            if (usr < 1000)
            {
                throw new ApplicationException("Invalid userID");
            }

            try
            {
                if (UserRoleAccessor.UpdateUserRoleRemove(usr, role) == 1)
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(false);
        }
コード例 #5
0
        // should not be used after approval
        public bool EditUserRole(UserRole userRole)
        {
            if (userRole.UserID < 1000)
            {
                throw new ApplicationException("Invalid userID");
            }

            try
            {
                if (UserRoleAccessor.UpdateUserRole(userRole) == 1)
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(false);
        }
コード例 #6
0
 public bool AddNewUserRole(int userId,
                            string roleId)
 {
     try
     {
         var userRole = new UserRole()
         {
             UserID = userId,
             RoleID = roleId
         };
         if (UserRoleAccessor.InsertUserRole(userRole) == 1)
         {
             return(true);
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(false);
 }