public async Task RootDimensionStructureNodeIsAddedToSourceFormat(Table table)
        {
            RootDimensionStructureNodeIsAddedToSourceFormatEntity instance = table
                                                                             .CreateInstance <RootDimensionStructureNodeIsAddedToSourceFormatEntity>();

            SourceFormat sf = _scenarioContext.Get <SourceFormat>(instance.SourceFormatResultKey);

            Check.IsNotNull(sf);
            DimensionStructureNode dsn = _scenarioContext.Get <DimensionStructureNode>(
                instance.DimensionStructureNodeResultKey);

            Check.IsNotNull(dsn);

            AddRootDimensionStructureNodeViewModel vm = new AddRootDimensionStructureNodeViewModel()
            {
                DimensionStructureNodeId = dsn.Id,
                SourceFormatId           = sf.Id,
            };

            DilibHttpClientResponse <SourceFormat> result = await _masterDataHttpClient.SourceFormatHttpClient
                                                            .AddRootDimensionStructureNodeAsync(vm)
                                                            .ConfigureAwait(false);

            _scenarioContext.Add(instance.ResultKey, result);
        }
        public async Task DimensionStructureNodeIsAddedToSourceFormatAsRootDimensionStructureNode(Table table)
        {
            DimensionStructureNodeIsAddedToSourceFormatAsRootDimensionStructureNodeEntity instance = table
                                                                                                     .CreateInstance <DimensionStructureNodeIsAddedToSourceFormatAsRootDimensionStructureNodeEntity>();

            bool doesSourceFormatExist           = GetKeyValueFromScenarioContext <bool>(ScenarioContextKeys.SourceFormatExist);
            bool doesDimensionStructureNodeExist =
                GetKeyValueFromScenarioContext <bool>(ScenarioContextKeys.DimensionStructureNodeIdExist);
            long sourceFormatIdFromContext           = GetKeyValueFromScenarioContext <long>(ScenarioContextKeys.SourceFormatId);
            long dimensionStructureNodeIdFromContext =
                GetKeyValueFromScenarioContext <long>(ScenarioContextKeys.DimensionStructureNodeId);

            long dimensionStructureNodeId = 0;
            long sourceFormatId           = 0;

            if (doesSourceFormatExist)
            {
                SourceFormat sourceFormat = await CreateSourceFormatEntity().ConfigureAwait(false);

                sourceFormatId = sourceFormat.Id;
            }
            else
            {
                sourceFormatId = sourceFormatIdFromContext;
            }

            if (doesDimensionStructureNodeExist)
            {
                DimensionStructureNode node = await CreateDimensionStructureNodeEntity().ConfigureAwait(false);

                dimensionStructureNodeId = node.Id;
            }
            else
            {
                dimensionStructureNodeId = dimensionStructureNodeIdFromContext;
            }

            AddRootDimensionStructureNodeViewModel addRootDimensionStructureNodeViewModel =
                new AddRootDimensionStructureNodeViewModel
            {
                SourceFormatId           = sourceFormatId,
                DimensionStructureNodeId = dimensionStructureNodeId,
            };

            DilibHttpClientResponse <SourceFormat> result = await _masterDataHttpClient
                                                            .SourceFormatHttpClient
                                                            .AddRootDimensionStructureNodeAsync(addRootDimensionStructureNodeViewModel)
                                                            .ConfigureAwait(false);

            _scenarioContext.Add(instance.ResultKey, result);
        }
예제 #3
0
        /// <inheritdoc/>
        public async Task <DilibHttpClientResponse <SourceFormat> > AddRootDimensionStructureNodeAsync(
            AddRootDimensionStructureNodeViewModel addRootDimensionStructureNodeViewModel,
            CancellationToken cancellationToken = default)
        {
            Check.IsNotNull(addRootDimensionStructureNodeViewModel);

            string url = $"{SourceFormatBase}/{MasterDataApi.SourceFormat.V1.AddRootDimensionStructureNode}";
            DilibHttpClientResponse <SourceFormat> result = await _diLibHttpClient
                                                            .PostAsync <SourceFormat, AddRootDimensionStructureNodeViewModel>(
                url,
                addRootDimensionStructureNodeViewModel,
                cancellationToken
                )
                                                            .ConfigureAwait(false);

            return(result);
        }
        public async Task <ActionResult> AddRootDimensionStructureNodeAsync(
            AddRootDimensionStructureNodeViewModel addRootDimensionStructureNodeViewModel)
        {
            try
            {
                await _masterDataBusinessLogic
                .MasterDataSourceFormatBusinessLogic
                .AddRootDimensionStructureNodeAsync(
                    addRootDimensionStructureNodeViewModel.SourceFormatId,
                    addRootDimensionStructureNodeViewModel.DimensionStructureNodeId)
                .ConfigureAwait(false);

                return(Ok());
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }
        }