public async Task <IActionResult> CreateWorkplaceCredentials([FromRoute] Guid departmentId, [FromBody] WorkplaceCredentialsRequestDto request)
        {
            var areScopesOk = WorkplaceScopesValidator.CheckRequestedDepartmentWorkplaceScopes(request);

            if (!areScopesOk.Item1)
            {
                return(BadRequest(areScopesOk.Item2));
            }

            // get the department in order to extract org structure attributes
            var department = await _departmentService.GetAsync(departmentId);

            // TODO: add authorization check here

            // build workplace descriptor
            var descriptor = new WorkplaceDescriptorDto
            {
                Scopes         = request.Scopes.Split(' '),
                BranchOfficeId = department.BranchOfficeId.ToString(),
                DepartmentId   = departmentId.ToString(),
                TenantId       = department.TenantId.ToString(),
                WorkplaceType  = "dwp",
                DisplayName    = $"Department workplace ({department.Name})"
            };

            var credentials = await _workplaceCredentialsService.CreateWorkplaceAsync(descriptor);

            return(Ok(credentials));
        }
        public async Task <IActionResult> CreateWorkplaceCredentials([FromRoute] Guid branchOfficeId, [FromBody] WorkplaceCredentialsRequestDto request)
        {
            var areScopesOk = WorkplaceScopesValidator.CheckRequestedBranchWorkplaceScopes(request);

            if (!areScopesOk.Item1)
            {
                return(BadRequest(areScopesOk.Item2));
            }

            var branchOffice = await _branchOfficeService.GetAsync(branchOfficeId);

            // TODO: add authorization check here

            // build workplace descriptor
            var descriptor = new WorkplaceDescriptorDto
            {
                Scopes         = request.Scopes.Split(' '),
                BranchOfficeId = branchOfficeId.ToString(),
                DepartmentId   = null,
                TenantId       = branchOffice.TenantId.ToString(),
                WorkplaceType  = "bwp",
                DisplayName    = $"Branch workplace ({branchOffice.Name})"
            };

            var credentials = await _workplaceCredentialsService.CreateWorkplaceAsync(descriptor);

            return(Ok(credentials));
        }