Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apr 1152 store not required rules #532

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1c81450
APR-1152 add not required overrides JSON field to Apply table
David-B-Read Apr 28, 2020
183e5a4
APR-1152 internal API to read/write not required override config
David-B-Read Apr 28, 2020
4b8faf9
APR-1152 update not required overrides service to persist data via API
David-B-Read Apr 28, 2020
9594b49
APR-1152 add unit tests for not required override handlers
David-B-Read Apr 28, 2020
b0225b3
Merge branch 'APR-1356_task_list_view_model_tech_debt' into APR-1152_…
David-B-Read Jun 2, 2020
c59fa36
APR-1152 fix field duplicated in merge
David-B-Read Jun 2, 2020
e193f03
APR-1152b merged in master and trying to sort out issues
MarkFCain Aug 18, 2020
46a3553
APR-1152b updated broken tests
MarkFCain Aug 19, 2020
a0b5575
APR-1152b merged in master
MarkFCain Aug 19, 2020
6541243
APR-1152b cleaned up commented out stuff
MarkFCain Aug 19, 2020
28b10fe
APR-1152b added in retrieval from appData
MarkFCain Aug 19, 2020
19fbb1e
Merge pull request #577 from SkillsFundingAgency/APR-1152b_merge_issues
MarkFCain Aug 19, 2020
195f1d5
APR-1152 updated interaction code and coverage for appData
MarkFCain Aug 20, 2020
ce7108d
APR-1152 - Make test Async
martin-lush Aug 21, 2020
fa26b49
Tidy up from merge
martin-lush Aug 21, 2020
bef548a
Merge branch 'master' into APR-1152_store_not_required_rules
MarkFCain Aug 26, 2020
b488c17
APR-1152 added in async
MarkFCain Aug 27, 2020
032a8db
APR-1152 reworking some async calls
MarkFCain Aug 27, 2020
72807d7
APR-1152 added logging to notRequiredOverrides service
MarkFCain Sep 1, 2020
c91802a
APR-1152 added logging to api side
MarkFCain Sep 1, 2020
96329ed
APR-1152 removed unneeded filter variable
MarkFCain Sep 1, 2020
49a2961
APR-1152 cleaned up getnotrequiredoverrides handler
MarkFCain Sep 1, 2020
4e2a92d
APR-1152 minor addition to override handler
MarkFCain Sep 1, 2020
17e9ec8
APR-1152 added logging to SaveAnswersGiven where it updates not requi…
MarkFCain Sep 1, 2020
afd7c00
APR-1152 minor typo correction
MarkFCain Sep 1, 2020
9e42904
APR-1152 - Code tidy up
martin-lush Sep 10, 2020
8134987
APR-1152 - Refactored code to ensure appropriate retrieval of NotRequ…
martin-lush Sep 10, 2020
a2b2260
APR-1152 - Use async calls to RefreshNotRequiredOverrides
martin-lush Sep 10, 2020
d43e343
Merge branch 'master' into APR-1152_store_not_required_rules
martin-lush Sep 11, 2020
4b3a377
APR-1152 refreshed from master
MarkFCain Oct 8, 2020
9e3ebd7
Merge branch 'master' of https://github.com/SkillsFundingAgency/das-a…
Oct 15, 2020
0bc8230
APR-1152 - Added a couple of tweaks
martin-lush Oct 16, 2020
a91f50f
APR-1152 - Optimise GetApplicationSequences in RoatpTaskListWorkflowS…
martin-lush Oct 16, 2020
f041efd
Pass app sequences into tasklist ctor
chrisfoster76 Oct 19, 2020
4f849c5
Merge pull request #600 from SkillsFundingAgency/pass-app-sequences-i…
chrisfoster76 Oct 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using SFA.DAS.ApplyService.Application.Apply.Roatp;
using SFA.DAS.ApplyService.Application.Apply.Submit;
using SFA.DAS.ApplyService.Domain.Apply;
using SFA.DAS.ApplyService.Domain.Entities;
Expand Down Expand Up @@ -93,6 +94,10 @@ public interface IApplyRepository
Task<bool> IsSectionCompleted(Guid applicationId, Guid applicationSectionId);

Task RemoveSectionCompleted(Guid applicationId, Guid applicationSectionId);

Task<NotRequiredOverrideConfiguration> GetNotRequiredOverrides(Guid applicationId);

Task<bool> SaveNotRequiredOverrides(Guid applicationId, NotRequiredOverrideConfiguration notRequiredOverrides);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

using MediatR;
using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace SFA.DAS.ApplyService.Application.Apply.Roatp
{
public class GetNotRequiredOverridesHandler : IRequestHandler<GetNotRequiredOverridesRequest, NotRequiredOverrideConfiguration>
{
private readonly IApplyRepository _applyRepository;
private readonly ILogger<GetNotRequiredOverridesHandler> _logger;

public GetNotRequiredOverridesHandler(IApplyRepository applyRepository, ILogger<GetNotRequiredOverridesHandler> logger)
{
_applyRepository = applyRepository;
_logger = logger;
}

public async Task<NotRequiredOverrideConfiguration> Handle(GetNotRequiredOverridesRequest request, CancellationToken cancellationToken)
{
var configuration = await _applyRepository.GetNotRequiredOverrides(request.ApplicationId);
return await Task.FromResult(configuration);
}
}
}
MarkFCain marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using MediatR;
using System;
using System.Collections.Generic;

namespace SFA.DAS.ApplyService.Application.Apply.Roatp
{
public class GetNotRequiredOverridesRequest : IRequest<NotRequiredOverrideConfiguration>
{
public Guid ApplicationId { get; }

public GetNotRequiredOverridesRequest(Guid applicationId)
{
ApplicationId = applicationId;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Collections.Generic;

namespace SFA.DAS.ApplyService.Application.Apply.Roatp
{
public class NotRequiredOverride
{
public int SequenceId { get; set; }
public int SectionId { get; set; }
public List<NotRequiredCondition> Conditions { get; set; }
}

public class NotRequiredCondition
{
public string ConditionalCheckField { get; set; }
public string MustEqual { get; set; }
public string Value { get; set; }
}

public class NotRequiredOverrideConfiguration
{
public IEnumerable<NotRequiredOverride> NotRequiredOverrides { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using MediatR;
using Microsoft.Extensions.Logging;
using System;
using System.Threading;
using System.Threading.Tasks;

namespace SFA.DAS.ApplyService.Application.Apply.Roatp
{
public class UpdateNotRequiredOverridesHandler : IRequestHandler<UpdateNotRequiredOverridesRequest, bool>
{
private readonly IApplyRepository _applyRepository;
private readonly ILogger<UpdateNotRequiredOverridesHandler> _logger;

public UpdateNotRequiredOverridesHandler(IApplyRepository applyRepository, ILogger<UpdateNotRequiredOverridesHandler> logger)
{
_applyRepository = applyRepository;
_logger = logger;
}

public async Task<bool> Handle(UpdateNotRequiredOverridesRequest request, CancellationToken cancellationToken)
{
return await _applyRepository.SaveNotRequiredOverrides(request.ApplicationId, request.NotRequiredOverrides);
}
}
}
MarkFCain marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using MediatR;
using System;
using System.Collections.Generic;

namespace SFA.DAS.ApplyService.Application.Apply.Roatp
{
public class UpdateNotRequiredOverridesRequest : IRequest<bool>
{
public Guid ApplicationId { get; }
public NotRequiredOverrideConfiguration NotRequiredOverrides { get; }

public UpdateNotRequiredOverridesRequest(Guid applicationId, NotRequiredOverrideConfiguration notRequiredOverrides)
{
ApplicationId = applicationId;
NotRequiredOverrides = notRequiredOverrides;
}
}
}
30 changes: 30 additions & 0 deletions src/SFA.DAS.ApplyService.Data/ApplyRepository.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using SFA.DAS.ApplyService.Application.Apply;
using SFA.DAS.ApplyService.Application.Apply.Roatp;
using SFA.DAS.ApplyService.Configuration;
using SFA.DAS.ApplyService.Data.DapperTypeHandlers;
using SFA.DAS.ApplyService.Domain.Apply;
Expand Down Expand Up @@ -29,6 +31,7 @@ public ApplyRepository(IConfigurationService configurationService, ILogger<Apply
SqlMapper.AddTypeHandler(typeof(QnAData), new QnADataHandler());
SqlMapper.AddTypeHandler(typeof(ApplicationData), new ApplicationDataHandler());
SqlMapper.AddTypeHandler(typeof(FinancialReviewDetails), new FinancialReviewDetailsDataHandler());
SqlMapper.AddTypeHandler(typeof(NotRequiredOverrideConfiguration), new NotRequiredOverrideDataHandler());
}

public async Task<Guid> StartApplication(Guid applicationId, ApplyData applyData, Guid organisationId, Guid createdBy)
Expand Down Expand Up @@ -1208,5 +1211,32 @@ await connection.ExecuteAsync(@"UPDATE Apply SET ApplyData = @applyData,
return await Task.FromResult(true);
}

public async Task<NotRequiredOverrideConfiguration> GetNotRequiredOverrides(Guid applicationId)
{
using (var connection = new SqlConnection(_config.SqlConnectionString))
{
var applyDataResults = await connection.QueryAsync<NotRequiredOverrideConfiguration>(@"SELECT NotRequiredOverrides FROM Apply WHERE ApplicationId = @applicationId",
new { applicationId });

return applyDataResults.FirstOrDefault();
}
}

public async Task<bool> SaveNotRequiredOverrides(Guid applicationId, NotRequiredOverrideConfiguration notRequiredOverrides)
{
using (var connection = new SqlConnection(_config.SqlConnectionString))
{
await connection.ExecuteAsync(@"UPDATE Apply SET NotRequiredOverrides = @notRequiredOverrides
WHERE ApplicationId = @applicationId",
new
{
applicationId,
notRequiredOverrides
});
}

return await Task.FromResult(true);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Dapper;
using Newtonsoft.Json;
using SFA.DAS.ApplyService.Application.Apply.Roatp;
using System.Data;

namespace SFA.DAS.ApplyService.Data.DapperTypeHandlers
{
public class NotRequiredOverrideDataHandler : SqlMapper.TypeHandler<NotRequiredOverrideConfiguration>
{
public override NotRequiredOverrideConfiguration Parse(object value)
{
return JsonConvert.DeserializeObject<NotRequiredOverrideConfiguration>(value.ToString());
}

public override void SetValue(IDbDataParameter parameter, NotRequiredOverrideConfiguration value)
{
parameter.Value = JsonConvert.SerializeObject(value);
}
}
}
3 changes: 2 additions & 1 deletion src/SFA.DAS.ApplyService.Database/Tables/Apply.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
[UpdatedBy] NVARCHAR(256) NULL,
[DeletedAt] DATETIME2 NULL,
[DeletedBy] NVARCHAR(256) NULL,
[UKPRN] AS JSON_VALUE(ApplyData, '$.ApplyDetails.UKPRN') PERSISTED
[UKPRN] AS JSON_VALUE(ApplyData, '$.ApplyDetails.UKPRN') PERSISTED,
[NotRequiredOverrides] NVARCHAR(MAX) NULL
)
GO
CREATE INDEX [IX_Apply_ApplicationId] ON [Apply] ([ApplicationId])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using SFA.DAS.ApplyService.Application.Apply.Roatp;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace SFA.DAS.ApplyService.InternalApi.Controllers
{
[Authorize]
public class NotRequiredOverridesController : Controller
{
private readonly IMediator _mediator;
private readonly ILogger<NotRequiredOverridesController> _logger;

public NotRequiredOverridesController(IMediator mediator, ILogger<NotRequiredOverridesController> logger)
{
_mediator = mediator;
_logger = logger;
}

[HttpGet("NotRequiredOverrides/{applicationId}")]
public async Task<IActionResult> GetNotRequiredOverrides(Guid applicationId)
{
return Ok(await _mediator.Send(new GetNotRequiredOverridesRequest(applicationId)));
}

[HttpPost("NotRequiredOverrides/{applicationId}")]
public async Task<IActionResult> SaveNotRequiredOverrides(Guid applicationId, [FromBody] NotRequiredOverrideConfiguration notRequiredOverrides)
{
return Ok(await _mediator.Send(new UpdateNotRequiredOverridesRequest(applicationId, notRequiredOverrides)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using NotRequiredOverrideConfiguration = SFA.DAS.ApplyService.Web.Configuration.NotRequiredOverrideConfiguration;

namespace SFA.DAS.ApplyService.Web.UnitTests.Controllers
{
Expand Down
Loading