public async Task <EmailSettingsDto> GetEmailSettingsAsync(int userId)
        {
            await _privilegesManager.Demand(userId, InstanceAdminPrivileges.ViewInstanceSettings);

            EmailSettings settings = await _instanceSettingsRepository.GetEmailSettings();

            return((EmailSettingsDto)settings);
        }
示例#2
0
        public async Task <IHttpActionResult> GetUsers([FromUri] Pagination pagination, [FromUri] Sorting sorting = null, string search = null)
        {
            pagination.Validate();
            SearchFieldValidator.Validate(search);

            await _privilegesManager.Demand(Session.UserId, InstanceAdminPrivileges.ViewUsers);

            var result = await _userRepository.GetUsersAsync(pagination, sorting, search, SortingHelper.SortUsers);

            return(Ok(result));
        }
示例#3
0
        public async Task <IEnumerable <StandardArtifactType> > GetStandardArtifactTypes(StandardArtifactTypes filter = StandardArtifactTypes.All)
        {
            await _privilegesManager.Demand(Session.UserId, InstanceAdminPrivileges.AccessAllProjectData);

            if (filter != StandardArtifactTypes.All && filter != StandardArtifactTypes.Regular)
            {
                throw new BadRequestException(ErrorMessages.InvalidStandardArtifactTypesFilterValue);
            }

            return(await _artifactRepository.GetStandardArtifactTypes(filter));
        }
示例#4
0
        public async Task <InstanceItem> GetInstanceFolderAsync(int id, bool fromAdminPortal = false)
        {
            if (fromAdminPortal)
            {
                await _privilegesManager.Demand(Session.UserId, InstanceAdminPrivileges.ViewProjects);
            }

            return(await _instanceRepository.GetInstanceFolderAsync(id, Session.UserId, fromAdminPortal));
        }
示例#5
0
        public async Task <IHttpActionResult> GetGroups([FromUri] Pagination pagination, [FromUri] Sorting sorting = null, [FromUri] string search = null, int userId = 0)
        {
            pagination.Validate();
            SearchFieldValidator.Validate(search);

            if (userId < 0)
            {
                throw new BadRequestException(ErrorMessages.TheUserIdCanNotBeNegative, ErrorCodes.BadRequest);
            }

            var privileges = userId == 0 ? InstanceAdminPrivileges.ViewGroups : InstanceAdminPrivileges.ManageUsers;
            await _privilegesManager.Demand(Session.UserId, privileges);

            var tabularData = new TabularData {
                Pagination = pagination, Sorting = sorting, Search = search
            };
            var result = await _groupRepository.GetGroupsAsync(userId, tabularData, GroupsHelper.SortGroups);

            return(Ok(result));
        }
示例#6
0
        public async Task <IHttpActionResult> AssignProjectsAndArtifactTypesToWorkflow(int workFlowid, [FromBody] WorkflowAssignScope workflowAssign)
        {
            await _privilegesManager.Demand(Session.UserId, InstanceAdminPrivileges.AccessAllProjectData);

            if (workflowAssign == null)
            {
                throw new BadRequestException(ErrorMessages.AssignMemberScopeEmpty, ErrorCodes.BadRequest);
            }

            if (workflowAssign.IsEmpty())
            {
                return(Ok(AssignProjectsResult.Empty));
            }

            var result = await _workflowRepository.AssignProjectsAndArtifactTypesToWorkflow(workFlowid, workflowAssign);

            return(Ok(result));
        }