Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
@@ -0,0 +1,38 @@
// ---------------------------------------------------------
// Copyright (c) North East London ICB. All rights reserved.
// ---------------------------------------------------------

using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.OData.Query;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace LondonDataServices.IDecide.Manage.Server
{
public class ConfigurableEnableQueryAttribute : EnableQueryAttribute
{
public override void OnActionExecuting(ActionExecutingContext actionContext)
{
int pageSize;

var configuration = actionContext.HttpContext.RequestServices
.GetRequiredService<IConfiguration>();

var environment = actionContext.HttpContext.RequestServices
.GetRequiredService<IHostEnvironment>();

if (environment.IsDevelopment())
{
pageSize = configuration.GetValue<int>("OData:PageSize_Debug", 5000);
}
else
{
pageSize = configuration.GetValue<int>("OData:PageSize_Release", 50);
}

this.PageSize = pageSize;
base.OnActionExecuting(actionContext);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using LondonDataServices.IDecide.Core.Services.Foundations.ConsumerAdoptions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using RESTFulSense.Controllers;

namespace LondonDataServices.IDecide.Manage.Server.Controllers
Expand Down Expand Up @@ -60,12 +59,7 @@ public async ValueTask<ActionResult<ConsumerAdoption>> PostConsumerAdoptionAsync
}

[HttpGet]
#if !DEBUG
[EnableQuery(PageSize = 50)]
#endif
#if DEBUG
[EnableQuery(PageSize = 5000)]
#endif
[ConfigurableEnableQuery]
[Authorize(Roles = "LondonDataServices.IDecide.Manage.Server.Administrators,LondonDataServices.IDecide.Manage.Server.Consumers")]
public async ValueTask<ActionResult<IQueryable<ConsumerAdoption>>> Get()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using LondonDataServices.IDecide.Core.Services.Foundations.Consumers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using RESTFulSense.Controllers;

namespace LondonDataServices.IDecide.Manage.Server.Controllers
Expand Down Expand Up @@ -60,12 +59,7 @@ public async ValueTask<ActionResult<Consumer>> PostConsumerAsync([FromBody] Cons
}

[HttpGet]
#if !DEBUG
[EnableQuery(PageSize = 50)]
#endif
#if DEBUG
[EnableQuery(PageSize = 20)]
#endif
[ConfigurableEnableQuery]
[Authorize(Roles = "LondonDataServices.IDecide.Manage.Server.Administrators")]
public async ValueTask<ActionResult<IQueryable<Consumer>>> Get()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using LondonDataServices.IDecide.Core.Services.Foundations.DecisionTypes;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using RESTFulSense.Controllers;

namespace LondonDataServices.IDecide.Manage.Server.Controllers
Expand Down Expand Up @@ -60,12 +59,7 @@ public async ValueTask<ActionResult<DecisionType>> PostDecisionTypeAsync([FromBo
}

[HttpGet]
#if !DEBUG
[EnableQuery(PageSize = 50)]
#endif
#if DEBUG
[EnableQuery(PageSize = 5000)]
#endif
[ConfigurableEnableQuery]
[Authorize(Roles = "LondonDataServices.IDecide.Manage.Server.Administrators,LondonDataServices.IDecide.Manage.Server.Agents")]
public async ValueTask<ActionResult<IQueryable<DecisionType>>> Get()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using LondonDataServices.IDecide.Core.Services.Foundations.Decisions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using RESTFulSense.Controllers;

namespace LondonDataServices.IDecide.Manage.Server.Controllers
Expand Down Expand Up @@ -60,12 +59,7 @@ public async ValueTask<ActionResult<Decision>> PostDecisionAsync([FromBody] Deci
}

[HttpGet]
#if !DEBUG
[EnableQuery(PageSize = 50)]
#endif
#if DEBUG
[EnableQuery(PageSize = 5000)]
#endif
[ConfigurableEnableQuery]
[Authorize(Roles = "LondonDataServices.IDecide.Manage.Server.Administrators,LondonDataServices.IDecide.Manage.Server.Agents")]
public async ValueTask<ActionResult<IQueryable<Decision>>> Get()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using LondonDataServices.IDecide.Core.Services.Foundations.Patients;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using RESTFulSense.Controllers;

namespace LondonDataServices.IDecide.Manage.Server.Controllers
Expand Down Expand Up @@ -60,12 +59,7 @@ public async ValueTask<ActionResult<Patient>> PostPatientAsync([FromBody] Patien
}

[HttpGet]
#if !DEBUG
[EnableQuery(PageSize = 50)]
#endif
#if DEBUG
[EnableQuery(PageSize = 5000)]
#endif
[ConfigurableEnableQuery]
[Authorize(Roles = "LondonDataServices.IDecide.Manage.Server.Administrators,LondonDataServices.IDecide.Manage.Server.Agents")]
public async ValueTask<ActionResult<IQueryable<Patient>>> Get()
{
Expand Down
6 changes: 4 additions & 2 deletions LondonDataServices.IDecide.Manage.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using LondonDataServices.IDecide.Core.Models.Foundations.ConsumerAdoptions;
using LondonDataServices.IDecide.Core.Models.Foundations.Consumers;
using LondonDataServices.IDecide.Core.Models.Foundations.Decisions;
using LondonDataServices.IDecide.Core.Models.Foundations.DecisionTypes;
using LondonDataServices.IDecide.Core.Models.Foundations.Notifications;
using LondonDataServices.IDecide.Core.Models.Foundations.Patients;
using LondonDataServices.IDecide.Core.Models.Orchestrations.Decisions;
Expand Down Expand Up @@ -186,10 +187,11 @@ private static IEdmModel GetEdmModel()
new ODataConventionModelBuilder();

builder.EntitySet<Audit>("Audits");
builder.EntitySet<Patient>("Patients");
builder.EntitySet<Decision>("Decisions");
builder.EntitySet<Consumer>("Consumers");
builder.EntitySet<Decision>("Decisions");
builder.EntitySet<Patient>("Patients");
builder.EntitySet<ConsumerAdoption>("ConsumerAdoptions");
builder.EntitySet<DecisionType>("DecisionTypes");
builder.EnableLowerCamelCase();

return builder.GetEdmModel();
Expand Down
4 changes: 4 additions & 0 deletions LondonDataServices.IDecide.Manage.Server/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"Microsoft.AspNetCore": "Warning"
}
},
"OData": {
"PageSize_Debug": 5000,
"PageSize_Release": 50
},
"ConnectionStrings": {
"IDecideConnectionString": "Server=(localdb)\\MSSQLLocalDB;Database=IDecide;Trusted_Connection=True;MultipleActiveResultSets=true"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// ---------------------------------------------------------
// Copyright (c) North East London ICB. All rights reserved.
// ---------------------------------------------------------

using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.OData.Query;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace LondonDataServices.IDecide.Portal.Server
{
public class ConfigurableEnableQueryAttribute : EnableQueryAttribute
{
public override void OnActionExecuting(ActionExecutingContext actionContext)
{
int pageSize;

var configuration = actionContext.HttpContext.RequestServices
.GetRequiredService<IConfiguration>();

var environment = actionContext.HttpContext.RequestServices
.GetRequiredService<IHostEnvironment>();

if (environment.IsDevelopment())
{
pageSize = configuration.GetValue<int>("OData:PageSize_Debug", 5000);
}
else
{
pageSize = configuration.GetValue<int>("OData:PageSize_Release", 50);
}

this.PageSize = pageSize;
base.OnActionExecuting(actionContext);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using LondonDataServices.IDecide.Core.Services.Foundations.DecisionTypes;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using RESTFulSense.Controllers;

namespace LondonDataServices.IDecide.Portal.Server.Controllers
Expand Down Expand Up @@ -61,12 +60,7 @@ public async ValueTask<ActionResult<DecisionType>> PostDecisionTypeAsync([FromBo
}

[HttpGet]
#if !DEBUG
[EnableQuery(PageSize = 50)]
#endif
#if DEBUG
[EnableQuery(PageSize = 5000)]
#endif
[ConfigurableEnableQuery]
[InvisibleApi]
[Authorize(Roles = "LondonDataServices.IDecide.Portal.Server.Administrators")]
public async ValueTask<ActionResult<IQueryable<DecisionType>>> Get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using LondonDataServices.IDecide.Core.Services.Foundations.Decisions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using RESTFulSense.Controllers;

namespace LondonDataServices.IDecide.Portal.Server.Controllers
Expand Down Expand Up @@ -61,12 +60,7 @@ public async ValueTask<ActionResult<Decision>> PostDecisionAsync([FromBody] Deci
}

[HttpGet]
#if !DEBUG
[EnableQuery(PageSize = 50)]
#endif
#if DEBUG
[EnableQuery(PageSize = 5000)]
#endif
[ConfigurableEnableQuery]
[InvisibleApi]
[Authorize(Roles = "LondonDataServices.IDecide.Portal.Server.Administrators")]
public async ValueTask<ActionResult<IQueryable<Decision>>> Get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using LondonDataServices.IDecide.Core.Services.Foundations.Patients;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Query;
using RESTFulSense.Controllers;

namespace LondonDataServices.IDecide.Portal.Server.Controllers
Expand Down Expand Up @@ -61,12 +60,7 @@ public async ValueTask<ActionResult<Patient>> PostPatientAsync([FromBody] Patien
}

[HttpGet]
#if !DEBUG
[EnableQuery(PageSize = 50)]
#endif
#if DEBUG
[EnableQuery(PageSize = 5000)]
#endif
[ConfigurableEnableQuery]
[InvisibleApi]
[Authorize(Roles = "LondonDataServices.IDecide.Portal.Server.Administrators")]
public async ValueTask<ActionResult<IQueryable<Patient>>> Get()
Expand Down
9 changes: 3 additions & 6 deletions LondonDataServices.IDecide.Portal.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
using LondonDataServices.IDecide.Core.Clients.Audits;
using LondonDataServices.IDecide.Core.Models.Brokers.Securities;
using LondonDataServices.IDecide.Core.Models.Foundations.Audits;
using LondonDataServices.IDecide.Core.Models.Foundations.ConsumerAdoptions;
using LondonDataServices.IDecide.Core.Models.Foundations.Consumers;
using LondonDataServices.IDecide.Core.Models.Foundations.Decisions;
using LondonDataServices.IDecide.Core.Models.Foundations.DecisionTypes;
using LondonDataServices.IDecide.Core.Models.Foundations.Notifications;
Expand Down Expand Up @@ -197,12 +195,11 @@ private static IEdmModel GetEdmModel()
ODataConventionModelBuilder builder =
new ODataConventionModelBuilder();

builder.EntitySet<Consumer>("Consumers");
builder.EntitySet<ConsumerAdoption>("ConsumerAdoptions");
builder.EntitySet<DecisionType>("DecisionTypes");
builder.EntitySet<Audit>("Audits");
builder.EntitySet<Decision>("Decisions");
builder.EntitySet<Patient>("Patients");
builder.EntitySet<Audit>("Audits");
builder.EntitySet<DecisionType>("DecisionTypes");

builder.EnableLowerCamelCase();

return builder.GetEdmModel();
Expand Down
4 changes: 4 additions & 0 deletions LondonDataServices.IDecide.Portal.Server/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"Microsoft.AspNetCore": "Warning"
}
},
"OData": {
"PageSize_Debug": 5000,
"PageSize_Release": 50
},
"ConnectionStrings": {
"IDecideConnectionString": "Server=(localdb)\\MSSQLLocalDB;Database=IDecide;Trusted_Connection=True;MultipleActiveResultSets=true"
},
Expand Down
Loading