public async Task <IActionResult> SetProfileVariationPointers(
            [FromRoute] string specificationId,
            [FromBody] IEnumerable <ProfileVariationPointer> profileVariationPointer)
        {
            Guard.IsNullOrWhiteSpace(specificationId, nameof(specificationId));
            Guard.ArgumentNotNull(profileVariationPointer, nameof(profileVariationPointer));

            if (!await _authorizationHelper.DoesUserHavePermission(
                    User,
                    specificationId,
                    SpecificationActionTypes.CanEditSpecification))
            {
                return(new ForbidResult());
            }

            HttpStatusCode response =
                await _specificationsApiClient.SetProfileVariationPointers(specificationId, profileVariationPointer);

            if (response == HttpStatusCode.OK)
            {
                return(new OkObjectResult(response));
            }

            throw new InvalidOperationException($"An error occurred while updating profile variation pointers. Status code={response}");
        }
예제 #2
0
        public async Task SetProfileVariationPointers_Returns_OK_Given_A_Valid_SpecificationId_And_ProfileVariationPointers()
        {
            SetupAuthorizedUser(SpecificationActionTypes.CanEditSpecification);
            string aValidSpecificationId = "ABC";
            List <ProfileVariationPointer> aValidProfileVariationPointers = CreateTestProfileVariationPointers().ToList();

            _specificationsApiClient
            .SetProfileVariationPointers(aValidSpecificationId, aValidProfileVariationPointers)
            .Returns(HttpStatusCode.OK);

            IActionResult result = await _specificationController.SetProfileVariationPointers(
                aValidSpecificationId,
                aValidProfileVariationPointers);

            result.Should().BeOfType <OkObjectResult>();
        }