HasSubjectFeatureAccess() public method

public HasSubjectFeatureAccess ( long subjectId, long featureId ) : bool
subjectId long
featureId long
return bool
Ejemplo n.º 1
0
        /// <summary>
        /// return true if user has edit rights
        /// </summary>
        /// <returns></returns>
        private bool hasUserEditAccessRights(long entityId)
        {
            #region security permissions and authorisations check
            // set edit rigths
            PermissionManager permissionManager = new PermissionManager();
            SubjectManager subjectManager = new SubjectManager();
            Security.Services.Objects.TaskManager securityTaskManager = new Security.Services.Objects.TaskManager();

            bool hasAuthorizationRights = false;

            User user = subjectManager.GetUserByName(GetUsernameOrDefault());
            long userid = -1;

            if (user != null)
            {
                userid = subjectManager.GetUserByName(GetUsernameOrDefault()).Id;

                //User has Access to Features
                //Area DCM
                //Controller "Create Dataset"
                //Action "*"
                Task task = securityTaskManager.GetTask("DCM", "CreateDataset", "*");
                if (task != null)
                {
                    hasAuthorizationRights = permissionManager.HasSubjectFeatureAccess(userid, task.Feature.Id);
                }

                return (hasAuthorizationRights);
            }
            else
            {
                return false;
            }

            #endregion
        }
Ejemplo n.º 2
0
        public ActionResult Subjects_Select(long id)
        {
            FeatureManager featureManager = new FeatureManager();

            // DATA
            Feature feature = featureManager.GetFeatureById(id);

            List<FeaturePermissionGridRowModel> featurePermissions = new List<FeaturePermissionGridRowModel>();

            if (feature != null)
            {
                PermissionManager permissionManager = new PermissionManager();
                SubjectManager subjectManager = new SubjectManager();

                IQueryable<Subject> data = subjectManager.GetAllSubjects();

                data.ToList().ForEach(s => featurePermissions.Add(FeaturePermissionGridRowModel.Convert(s, feature, permissionManager.GetFeaturePermissionType(s.Id, feature.Id), permissionManager.HasSubjectFeatureAccess(s.Id, feature.Id))));
            }

            return View(new GridModel<FeaturePermissionGridRowModel> { Data = featurePermissions });
        }