Ejemplo n.º 1
0
        public async Task HowToBecomeSegmentServicePatchSimpleClassificationReturnsExceptionWhenPatchmodelIsNull()
        {
            // arrange
            PatchSimpleClassificationModel patchModel = null;
            var documentId = Guid.NewGuid();

            // act
            var exceptionResult = await Assert.ThrowsAsync <ArgumentNullException>(async() => await howToBecomeSegmentService.PatchSimpleClassificationAsync(patchModel, documentId).ConfigureAwait(false)).ConfigureAwait(false);

            // assert
            Assert.Equal("Value cannot be null. (Parameter 'patchModel')", exceptionResult.Message);
        }
        public async Task <IActionResult> PatchEntryRequirement([FromBody] PatchSimpleClassificationModel patchSimpleClassificationModel, Guid documentId)
        {
            logService.LogInformation($"{PatchSimpleClassificationActionName} has been called");

            if (patchSimpleClassificationModel == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var response = await howToBecomeSegmentService.PatchSimpleClassificationAsync(patchSimpleClassificationModel, documentId).ConfigureAwait(false);

            if (response != HttpStatusCode.OK && response != HttpStatusCode.Created)
            {
                logService.LogError($"{PatchSimpleClassificationActionName}: Error while patching Entry Requirement content for Job Profile with Id: {patchSimpleClassificationModel.JobProfileId} for the {patchSimpleClassificationModel.RouteName.ToString()} link");
            }

            return(new StatusCodeResult((int)response));
        }