public async Task <ActionResult <ReProfileResponse> > ReProfile(ReProfileRequest reProfileRequest)
        {
            FundingStreamPeriodProfilePattern profilePattern = await _profilePatternService.GetProfilePattern(reProfileRequest.FundingStreamId,
                                                                                                              reProfileRequest.FundingPeriodId,
                                                                                                              reProfileRequest.FundingLineCode,
                                                                                                              reProfileRequest.ProfilePatternKey);

            if (profilePattern == null)
            {
                return(new NotFoundObjectResult("Profile pattern not found"));
            }

            if (profilePattern.ReProfilingConfiguration == null || !profilePattern.ReProfilingConfiguration.ReProfilingEnabled)
            {
                return(new BadRequestObjectResult("Re-profiling is not enabled or has not been configured"));
            }

            IReProfilingStrategy strategy = GetReProfilingStrategy(reProfileRequest, profilePattern);

            if (strategy == null)
            {
                return(new BadRequestObjectResult("Re-profiling is not enabled for this scenario or the strategy was not found"));
            }

            ReProfileContext context = CreateReProfilingContext(reProfileRequest, profilePattern);

            ReProfileStrategyResult strategyResult = strategy.ReProfile(context);

            VerifyProfileAmountsReturnedMatchRequestedFundingLineValue(reProfileRequest, strategyResult);

            return(new ReProfileResponse
            {
                DeliveryProfilePeriods = strategyResult.DeliveryProfilePeriods,
                DistributionPeriods = strategyResult.DistributionPeriods,
                ProfilePatternDisplayName = profilePattern.ProfilePatternDisplayName,
                ProfilePatternKey = profilePattern.ProfilePatternKey,
                CarryOverAmount = strategyResult.CarryOverAmount
            });
        }
 public async Task <IActionResult> GetProfilePattern([FromRoute] string id)
 {
     return(await _profilePatternService.GetProfilePattern(id));
 }