Skip to content

Commit

Permalink
Merge pull request #329 from SkillsFundingAgency/PA-436-Fix-when-no-c…
Browse files Browse the repository at this point in the history
…ourse-selected

PA-436 Fix when no course selected
  • Loading branch information
SreekanthBadigenchula authored Aug 5, 2022
2 parents 58ad477 + 167d885 commit 0e9c735
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal CommitmentsOuterApiBuilder WithCourseDeliveryModels()
{
_server
.Given(Request.Create()
.WithPath("/Providers/*/courses/*")
.WithPath("/Providers/*/courses*")
.UsingGet())
.RespondWith(Response.Create()
.WithStatusCode(HttpStatusCode.OK)
Expand All @@ -38,18 +38,6 @@ internal CommitmentsOuterApiBuilder WithCourseDeliveryModels()
DeliveryModels = new[] { "Regular", "PortableFlexiJob"},
}));

_server
.Given(Request.Create()
.WithPath("/Providers/*/courses/650")
.UsingGet())
.RespondWith(Response.Create()
.WithStatusCode(HttpStatusCode.OK)
.WithHeader("Content-Type", "application/json")
.WithBodyAsJson(new
{
DeliveryModels = new[] { "Regular" },
}));

return this;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System;
using System.Linq;
using System.Threading.Tasks;
using SFA.DAS.EmployerCommitmentsV2.Services.Approvals;
using SFA.DAS.Encoding;
Expand All @@ -19,7 +20,6 @@ public DeliveryModelService(IApprovalsApiClient approvalsApiClient, IEncodingSer
public async Task<bool> HasMultipleDeliveryModels(long providerId, string courseCode, string accountLegalEntity)
{
var aleId = _encodingService.Decode(accountLegalEntity, EncodingType.PublicAccountLegalEntityId);

var response = await _approvalsApiClient.GetProviderCourseDeliveryModels(providerId, courseCode, aleId);
return (response?.DeliveryModels.Count() > 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@
@Html.HiddenFor(x => x.StandardUId)

@{
var editCourseLabel = "Add";
var startDateLabel = Model.DeliveryModel == DeliveryModel.Regular ? "Planned training start date" : "Planned apprenticeship training start date";
var endDateLabel = Model.DeliveryModel == DeliveryModel.Regular ? "Projected training finish date" : "Projected apprenticeship training finish date";
var multipleDeliveryModels = await DeliveryModelService.HasMultipleDeliveryModels(Model.ProviderId, Model.CourseCode, Model.AccountLegalEntityHashedId);

if (!string.IsNullOrWhiteSpace(Model.CourseCode))
{
editCourseLabel = "Edit";
}

ViewBag.ValidationOrder = "FirstName,LastName,Email,DateOfBirth,Uln,StartDate,EndDate,EmploymentEndDate,Cost,EmploymentPrice,Reference";
}

Expand Down Expand Up @@ -163,7 +169,7 @@ else
<p class="govuk-body">
@Model.CourseName
<button type="submit" name="ChangeCourse" value="Edit" class="das-button--inline-link">
Edit<span class="govuk-visually-hidden"> aprenticeship training course</span>
@editCourseLabel<span class="govuk-visually-hidden"> apprenticeship training course</span>
</button>
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using System.Threading;
using System.Threading.Tasks;



namespace SFA.DAS.EmployerCommitmentsV2.Services.Approvals
{
public class ApprovalsApiClient : IApprovalsApiClient
Expand All @@ -23,7 +21,7 @@ public async Task<GetPledgeApplicationResponse> GetPledgeApplication(int pledgeA

public async Task<ProviderCourseDeliveryModels> GetProviderCourseDeliveryModels(long providerId, string courseCode, long accountLegalEntityId = 0, CancellationToken cancellationToken = default)
{
return await _client.Get<ProviderCourseDeliveryModels>($"Providers/{providerId}/courses/{courseCode}?accountLegalEntityId={accountLegalEntityId}", null, cancellationToken);
return await _client.Get<ProviderCourseDeliveryModels>($"Providers/{providerId}/courses?trainingCode={courseCode}&accountLegalEntityId={accountLegalEntityId}", null, cancellationToken);
}
}
}

0 comments on commit 0e9c735

Please sign in to comment.