public async Task <IActionResult> SaveTimetable([FromBody] ReleaseTimetableViewModel viewModel)
        {
            if (!await _authorizationHelper.DoesUserHavePermission(
                    User,
                    viewModel.SpecificationId,
                    SpecificationActionTypes.CanEditSpecification))
            {
                return(new ForbidResult());
            }

            SpecificationPublishDateModel publishData = new SpecificationPublishDateModel
            {
                EarliestPaymentAvailableDate = viewModel.FundingDate,
                ExternalPublicationDate      = viewModel.StatementDate
            };

            HttpStatusCode publish =
                await _specificationsApiClient.SetPublishDates(viewModel.SpecificationId, publishData);

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

            if (publish == HttpStatusCode.BadRequest)
            {
                return(new BadRequestObjectResult(
                           Content("There was a problem with the data submitted. Please check and try again.")));
            }

            return(new NotFoundObjectResult(Content("Error. Not Found.")));
        }
        public async Task SaveTimetable_Returns_OK_Result_Given_User_Has_Required_Permission()
        {
            SetupAuthorizedUser(SpecificationActionTypes.CanEditSpecification);
            _specificationsApiClient.SetPublishDates(Arg.Any <string>(), Arg.Any <SpecificationPublishDateModel>())
            .Returns(HttpStatusCode.OK);

            DateTime fundingDate   = DateTime.Now.AddDays(-1);
            DateTime statementDate = DateTime.Now.AddMonths(-1);
            ReleaseTimetableViewModel releaseTimetableViewModel = new ReleaseTimetableViewModel
            {
                SpecificationId = "XYZ",
                FundingDate     = fundingDate,
                StatementDate   = statementDate
            };
            IActionResult result = await _publishController.SaveTimetable(releaseTimetableViewModel);

            result.Should().BeAssignableTo <OkObjectResult>();
            SpecificationPublishDateModel specificationPublishDateModelResult = result.As <OkObjectResult>().Value.As <SpecificationPublishDateModel>();

            specificationPublishDateModelResult.EarliestPaymentAvailableDate.Should().Be(fundingDate);
            specificationPublishDateModelResult.ExternalPublicationDate.Should().Be(statementDate);
        }