private List <AppSingleRole> GetSuperAdminSingleRole()
        {
            List <AppSingleRole> roleList = new List <AppSingleRole>();

            roleList = _unitOfWork.GetRepository <AppSingleRole>().GetCache().ToList();
            var role = new AppSingleRole
            {
                RoleId = ConstantValue.RoleSuperAdmin
            };

            roleList.Add(role);

            return(roleList);
        }
        public static List <AppSingleRole> GetRole(string username)
        {
            List <AppSingleRole> roleList = new List <AppSingleRole>();
            AppSingleRole        role     = new AppSingleRole();

#if DEBUG
            //For test, add super admin role
            role        = new AppSingleRole();
            role.RoleID = ConstantVariableService.RoleSuperAdmin;
            roleList.Add(role);

            roleList = GetSuperAdminSingleRole();
#endif

            try
            {
                using (var context = new PYMFEEEntities())
                {
                    var    user             = (from m in context.USERS where m.USERNAME == username select m).FirstOrDefault();
                    string userId           = user == null ? "" : user.USERID;
                    var    userCompRoleList = (from m in context.UserRoles
                                               join n in context.AppCompositeRoles on m.CompositeRoleID equals n.ID
                                               where m.USERID == userId //&&
                                                                        //n.Status == ConstantVariableService.ConfigStatusActive
                                               select m).ToList();

                    if (userCompRoleList.Any())
                    {
                        foreach (var compRole in userCompRoleList)
                        {
                            var compRoleItemList = (from m in context.AppCompositeRoleItems where m.CompositeRoleID == compRole.CompositeRoleID select m).ToList();

                            foreach (var compRoleItem in compRoleItemList)
                            {
                                role        = new AppSingleRole();
                                role.RoleID = compRoleItem.RoleID;
                                roleList.Add(role);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(roleList);
        }
        private List <AppSingleRole> GetRole(string username)
        {
            List <AppSingleRole> roleList = new List <AppSingleRole>();
            AppSingleRole        role     = new AppSingleRole();

#if DEBUG
            //For test, add super admin role
            role = new AppSingleRole
            {
                RoleId = ConstantValue.RoleSuperAdmin
            };
            roleList.Add(role);

            roleList = GetSuperAdminSingleRole();
#endif

            var user = _unitOfWork.GetRepository <UserRole>().GetCache(x => x.Username == username).FirstOrDefault();
            if (user != null)
            {
                var userCompRoleList = _unitOfWork.GetRepository <AppCompositeRole>().GetCache(
                    x => x.Status == ConstantValue.ConfigStatusActive &&
                    x.Id == user.CompositeRoleId).ToList();

                if (userCompRoleList.Any())
                {
                    foreach (var compRole in userCompRoleList)
                    {
                        var compRoleItemList = _unitOfWork.GetRepository <AppCompositeRoleItem>().GetCache(
                            m => m.CompositeRoleId == user.CompositeRoleId).ToList();

                        foreach (var compRoleItem in compRoleItemList)
                        {
                            role = new AppSingleRole();
                            if (!string.IsNullOrEmpty(compRoleItem.RoleId))
                            {
                                role.RoleId = compRoleItem.RoleId;
                                roleList.Add(role);
                            }
                        }
                    }
                }
            }


            return(roleList);
        }
        public static List <AppSingleRole> GetSuperAdminSingleRole()
        {
            List <AppSingleRole> roleList = new List <AppSingleRole>();

            try
            {
                using (var context = new PYMFEEEntities())
                {
                    roleList = (from m in context.AppSingleRoles select m).ToList();
                }
            }
            catch (Exception ex)
            {
            }

            var role = new AppSingleRole();

            role.RoleID = ConstantVariableService.RoleSuperAdmin;
            roleList.Add(role);

            return(roleList);
        }