private bool CanView(AgriUserRole role)
 {
     using (StructureMap.IContainer c = NestedContainer)
     {
         User user = Using<IUserRepository>(c).GetById(Using<IConfigService>(c).ViewModelParameters.CurrentUserId);
         if (user != null && user.Group != null)
         {
             bool canAccess = Using<IUserGroupRolesRepository>(c)
                 .GetByGroup(user.Group.Id)
                 .Any(s => s.UserRole == (int) role);
                       
             return canAccess;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
        private bool ViewAgriModules(User user,AgriUserRole role,SettingsKeys settingKey)
        {
            var settings = ObjectFactory.GetInstance<ISettingsRepository>();

            bool result = false;

            var canViewModuleSetting = settings.GetByKey(settingKey) != null ? settings.GetByKey(settingKey).Value : null;
            var canViewModuleRight = user.UserRoles.Contains(((int)role).ToString());

            if (canViewModuleSetting == null || Convert.ToBoolean(canViewModuleSetting)==false)
            {
                result = false;
                //return result;
            }
            if (canViewModuleSetting != null && Convert.ToBoolean(canViewModuleSetting))
            {   
                result = true;
                if (!canViewModuleRight)
                    result = false;

            }



            return result;


        }