Esempio n. 1
0
        public async Task <IHttpActionResult> GetColumnsAsync(int id, string search = null)
        {
            SearchFieldValidator.Validate(search);

            var result = await _collectionsService.GetColumnsAsync(id, Session.UserId, search);

            return(Ok(result));
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> SearchProjectsByName(int workflowId, string search = null)
        {
            await _privilegesManager.Demand(Session.UserId, InstanceAdminPrivileges.AccessAllProjectData);

            SearchFieldValidator.Validate(search);

            var result = await _workflowRepository.SearchProjectsByName(workflowId, search);

            return(Ok(result));
        }
Esempio n. 3
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));
        }
Esempio n. 4
0
        public async Task <IHttpActionResult> GetWorkflows([FromUri] Pagination pagination, [FromUri] Sorting sorting = null, string search = null)
        {
            pagination.Validate();
            SearchFieldValidator.Validate(search);

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

            var result = await _workflowRepository.GetWorkflows(pagination, sorting, search, SortingHelper.SortWorkflows);

            return(Ok(result));
        }
Esempio n. 5
0
        public async Task <IHttpActionResult> GetProjectArtifactTypesAssignedToWorkflowAsync(int workflowId, [FromUri] Pagination pagination, string search = null)
        {
            pagination.Validate();
            SearchFieldValidator.Validate(search);

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

            var availiableProjects = await _workflowRepository.GetProjectArtifactTypesAssignedtoWorkflowAsync(workflowId, pagination,
                                                                                                              search);

            return(Ok(availiableProjects));
        }
Esempio n. 6
0
        public async Task <IHttpActionResult> GetGroupsAndUsers([FromUri] Pagination pagination, [FromUri] Sorting sorting, string search = null, int groupId = 0)
        {
            pagination.Validate();
            SearchFieldValidator.Validate(search);

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

            var tabularData = new TabularData {
                Pagination = pagination, Sorting = sorting, Search = search
            };
            var result = await _groupRepository.GetGroupUsersAsync(groupId, tabularData, SortingHelper.SortUsergroups);

            return(Ok(result));
        }
Esempio n. 7
0
        public async Task <IHttpActionResult> GetProjectRoleAssignments(int projectId, [FromUri] Pagination pagination, [FromUri] Sorting sorting, string search = null)
        {
            pagination.Validate();
            SearchFieldValidator.Validate(search);

            await
            _privilegesManager.DemandAny(Session.UserId, projectId, InstanceAdminPrivileges.AccessAllProjectsAdmin,
                                         ProjectAdminPrivileges.ViewGroupsAndRoles);

            var tabularData = new TabularData {
                Pagination = pagination, Sorting = sorting, Search = search
            };
            var result = await _instanceRepository.GetProjectRoleAssignmentsAsync(projectId, tabularData, SortingHelper.SortProjectRolesAssignments);

            return(Ok(result));
        }
Esempio n. 8
0
        public async Task <IHttpActionResult> SearchProjectFolder([FromUri] Pagination pagination, [FromUri] Sorting sorting = null, string search = null)
        {
            pagination.Validate();
            SearchFieldValidator.Validate(search);

            var result =
                await
                _instanceRepository.GetProjectsAndFolders(Session.UserId,
                                                          new TabularData()
            {
                Pagination = pagination, Sorting = sorting, Search = search
            },
                                                          SortingHelper.SortProjectFolders);

            return(Ok(result));
        }
Esempio n. 9
0
        public async Task <IHttpActionResult> AssignMembers(int groupId, AssignScope scope, string search = null)
        {
            SearchFieldValidator.Validate(search);

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

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

            var result = await _groupRepository.AssignMembers(groupId, scope, search);

            return(Ok(new AssignResult()
            {
                TotalAssigned = result
            }));
        }
Esempio n. 10
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));
        }
Esempio n. 11
0
        public async Task <IHttpActionResult> DeleteGroups([FromBody] OperationScope scope, string search = null)
        {
            SearchFieldValidator.Validate(search);

            if (scope == null)
            {
                return(BadRequest(ErrorMessages.InvalidDeleteGroupsParameters));
            }

            if (scope.IsEmpty())
            {
                return(Ok(DeleteResult.Empty));
            }

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

            var deletedGroupIds = new List <int>();
            Func <IDbTransaction, long, Task> action = async(transaction, transactionId) =>
            {
                var groupIds = await _groupRepository.DeleteGroupsAsync(scope, search, transaction);

                deletedGroupIds.AddRange(groupIds);

                var topRevisionId = await _itemInfoRepository.GetTopRevisionId(transaction);

                var message = new UsersGroupsChangedMessage(new int[0], deletedGroupIds)
                {
                    TransactionId = transactionId,
                    RevisionId    = topRevisionId,
                    ChangeType    = UsersGroupsChangedType.Delete
                };
                await _sendMessageExecutor.Execute(_applicationSettingsRepository, _serviceLogRepository, message, transaction);
            };

            await RunInTransactionAsync(action);

            return(Ok(new DeleteResult {
                TotalDeleted = deletedGroupIds.Count
            }));
        }
Esempio n. 12
0
        public async Task <IHttpActionResult> UnassignProjectsAndArtifactTypesFromWorkflowAsync(int workflowId, [FromBody] OperationScope scope, string search = null)
        {
            await _privilegesManager.Demand(Session.UserId, InstanceAdminPrivileges.AccessAllProjectData);

            SearchFieldValidator.Validate(search);

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

            if (scope.IsEmpty())
            {
                return(Ok(DeleteResult.Empty));
            }

            var result = await _workflowRepository.UnassignProjectsAndArtifactTypesFromWorkflowAsync(workflowId, scope, search);

            return(Ok(new DeleteResult {
                TotalDeleted = result
            }));
        }
Esempio n. 13
0
        public async Task <IHttpActionResult> DeleteWorkflows([FromBody] OperationScope scope, string search = null)
        {
            SearchFieldValidator.Validate(search);

            if (scope == null)
            {
                return(BadRequest(ErrorMessages.InvalidDeleteWorkflowsParameters));
            }

            if (scope.IsEmpty())
            {
                return(Ok(DeleteResult.Empty));
            }

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

            var result = await _workflowService.DeleteWorkflows(scope, search, Session.UserId);

            return(Ok(new DeleteResult {
                TotalDeleted = result
            }));
        }
Esempio n. 14
0
        public async Task <IHttpActionResult> AddUserToGroups(int userId, [FromBody] OperationScope scope, string search = null)
        {
            SearchFieldValidator.Validate(search);

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

            if (scope.IsEmpty())
            {
                return(Ok(CreateResult.Empty));
            }

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

            var result = await _userRepository.AddUserToGroupsAsync(userId, scope, search);

            return(Ok(new CreateResult {
                TotalCreated = result
            }));
        }
Esempio n. 15
0
        public async Task <IHttpActionResult> DeleteRoleAssignment(int projectId, [FromBody] OperationScope scope, string search = null)
        {
            SearchFieldValidator.Validate(search);

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

            if (scope.IsEmpty())
            {
                return(Ok(DeleteResult.Empty));
            }

            await _privilegesManager.DemandAny(Session.UserId, projectId,
                                               InstanceAdminPrivileges.AccessAllProjectsAdmin, ProjectAdminPrivileges.ManageGroupsAndRoles);

            var result = await _instanceRepository.DeleteRoleAssignmentsAsync(projectId, scope, search);

            return(Ok(new DeleteResult {
                TotalDeleted = result
            }));
        }