public async Task <IActionResult> Post([FromBody] HowToBecomeSegmentModel upsertHowToBecomeSegmentModel)
        {
            logService.LogInformation($"{PostActionName} has been called");

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

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

            var existingDocument = await howToBecomeSegmentService.GetByIdAsync(upsertHowToBecomeSegmentModel.DocumentId).ConfigureAwait(false);

            if (existingDocument != null)
            {
                return(new StatusCodeResult((int)HttpStatusCode.AlreadyReported));
            }

            var response = await howToBecomeSegmentService.UpsertAsync(upsertHowToBecomeSegmentModel)
                           .ConfigureAwait(false);

            logService.LogInformation($"{PostActionName} has upserted content for: {upsertHowToBecomeSegmentModel.CanonicalName}");

            return(new StatusCodeResult((int)response));
        }
        public async Task HowToBecomeSegmentServiceUpsertReturnsCreatedWhenDocumentCreated()
        {
            // arrange
            var howToBecomeSegmentModel = A.Fake <HowToBecomeSegmentModel>();
            var expectedResult          = HttpStatusCode.Created;

            A.CallTo(() => repository.UpsertAsync(howToBecomeSegmentModel)).Returns(expectedResult);

            // act
            var result = await howToBecomeSegmentService.UpsertAsync(howToBecomeSegmentModel).ConfigureAwait(false);

            // assert
            A.CallTo(() => repository.UpsertAsync(howToBecomeSegmentModel)).MustHaveHappenedOnceExactly();
            Assert.Equal(expectedResult, result);
        }