diff --git a/src/api/Areas/Admin/Controllers/OrganizationController.cs b/src/api/Areas/Admin/Controllers/OrganizationController.cs
index c561cf43..0683b90b 100644
--- a/src/api/Areas/Admin/Controllers/OrganizationController.cs
+++ b/src/api/Areas/Admin/Controllers/OrganizationController.cs
@@ -8,6 +8,7 @@
using HSB.Keycloak;
using HSB.Core.Exceptions;
using Microsoft.AspNetCore.Http.Extensions;
+using Microsoft.Extensions.Caching.Memory;
namespace HSB.API.Areas.SystemAdmin.Controllers;
@@ -34,7 +35,9 @@ public class OrganizationController : ControllerBase
///
///
///
- public OrganizationController(IOrganizationService service, ILogger logger)
+ public OrganizationController(
+ IOrganizationService service,
+ ILogger logger)
{
_service = service;
_logger = logger;
@@ -96,6 +99,7 @@ public IActionResult Add(OrganizationModel model)
var result = _service.FindForId(model.Id, true);
if (result == null) return new BadRequestObjectResult(new ErrorResponseModel("Organization does not exist"));
+
return CreatedAtAction(nameof(GetForId), new { id = result.Id }, new OrganizationModel(result, true));
}
diff --git a/src/api/Areas/Dashboard/Controllers/OrganizationController.cs b/src/api/Areas/Dashboard/Controllers/OrganizationController.cs
index 5e9e1ba4..131e0115 100644
--- a/src/api/Areas/Dashboard/Controllers/OrganizationController.cs
+++ b/src/api/Areas/Dashboard/Controllers/OrganizationController.cs
@@ -31,9 +31,6 @@ public class OrganizationController : ControllerBase
private readonly ILogger _logger;
private readonly IOrganizationService _service;
private readonly IAuthorizationHelper _authorization;
- private readonly IMemoryCache _memoryCache;
- private const string HSB_CACHE_KEY = "organizations-hsb";
- private const string HSB_LIST_CACHE_KEY = "organizationsList-hsb";
#endregion
#region Constructors
@@ -41,17 +38,14 @@ public class OrganizationController : ControllerBase
/// Creates a new instance of a OrganizationController.
///
///
- ///
///
///
public OrganizationController(
IOrganizationService service,
- IMemoryCache memoryCache,
IAuthorizationHelper authorization,
ILogger logger)
{
_service = service;
- _memoryCache = memoryCache;
_authorization = authorization;
_logger = logger;
}
@@ -67,7 +61,6 @@ public OrganizationController(
[Produces(MediaTypeNames.Application.Json)]
[ProducesResponseType(typeof(IEnumerable), (int)HttpStatusCode.OK)]
[SwaggerOperation(Tags = new[] { "Organization" })]
- // [ResponseCache(VaryByQueryKeys = new[] { "*" }, Location = ResponseCacheLocation.Client, Duration = 60)]
public IActionResult Find()
{
var uri = new Uri(this.Request.GetDisplayUrl());
@@ -77,17 +70,8 @@ public IActionResult Find()
var isHSB = this.User.HasClientRole(ClientRole.HSB);
if (isHSB)
{
- if (_memoryCache.TryGetValue(HSB_CACHE_KEY, out IEnumerable? cachedItems))
- {
- return new JsonResult(cachedItems);
- }
var result = _service.Find(filter);
var model = result.Select(ci => new OrganizationModel(ci, true));
- var cacheOptions = new MemoryCacheEntryOptions()
- {
- AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(60)
- };
- _memoryCache.Set(HSB_CACHE_KEY, model, cacheOptions);
return new JsonResult(model);
}
else
@@ -110,7 +94,6 @@ public IActionResult Find()
[Produces(MediaTypeNames.Application.Json)]
[ProducesResponseType(typeof(IEnumerable), (int)HttpStatusCode.OK)]
[SwaggerOperation(Tags = new[] { "Organization" })]
- // [ResponseCache(VaryByQueryKeys = new[] { "*" }, Location = ResponseCacheLocation.Client, Duration = 60)]
public IActionResult FindList()
{
var uri = new Uri(this.Request.GetDisplayUrl());
@@ -120,16 +103,7 @@ public IActionResult FindList()
var isHSB = this.User.HasClientRole(ClientRole.HSB);
if (isHSB)
{
- if (_memoryCache.TryGetValue(HSB_LIST_CACHE_KEY, out IEnumerable? cachedItems))
- {
- return new JsonResult(cachedItems);
- }
var result = _service.FindList(filter);
- var cacheOptions = new MemoryCacheEntryOptions()
- {
- AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(60)
- };
- _memoryCache.Set(HSB_LIST_CACHE_KEY, result, cacheOptions);
return new JsonResult(result);
}
else