diff --git a/PARR.API/Contracts/V1/ApiRoutes.cs b/PARR.API/Contracts/V1/ApiRoutes.cs
index f869c6c8..24b1e8fe 100644
--- a/PARR.API/Contracts/V1/ApiRoutes.cs
+++ b/PARR.API/Contracts/V1/ApiRoutes.cs
@@ -301,6 +301,11 @@
public const string GetAll = Base + "/applications/";
}
+ public static class ApplicationType
+ {
+ public const string GetAll = Base + "/application-types/";
+ }
+
public static class EkStatus
{
public const string GetAll = Base + "/ek-statuses/";
diff --git a/PARR.API/Contracts/V1/Requests/Queries/ApplicationQuery.cs b/PARR.API/Contracts/V1/Requests/Queries/ApplicationQuery.cs
index 0a395837..fa3d2a61 100644
--- a/PARR.API/Contracts/V1/Requests/Queries/ApplicationQuery.cs
+++ b/PARR.API/Contracts/V1/Requests/Queries/ApplicationQuery.cs
@@ -11,8 +11,8 @@ namespace PARR.API.Contracts.V1.Requests.Queries
///
- /// Поиск по типу: 0 - APP, 1 - OS, 2 - DB
+ /// Поиск по типу
///
- public ApplicationTypesEnum? Type { get; set; }
+ public Guid? TypeId { get; set; }
}
}
diff --git a/PARR.API/Controllers/V1/ApplicationController.cs b/PARR.API/Controllers/V1/ApplicationController.cs
index 3db63e5b..49ce3fa4 100644
--- a/PARR.API/Controllers/V1/ApplicationController.cs
+++ b/PARR.API/Controllers/V1/ApplicationController.cs
@@ -1,6 +1,5 @@
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Cors.Infrastructure;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using PARR.API.Contracts.V1;
@@ -23,17 +22,14 @@ namespace PARR.API.Controllers.V1
[Authorize(Roles = ParrRoles.Administrator.Role)]
public class ApplicationController : BaseApiController
{
- private readonly ILogger logger;
private readonly IMapper mapper;
private readonly IApplicationService applicationService;
public ApplicationController(
- ILogger logger,
IMapper mapper,
IApplicationService applicationService
)
{
- this.logger = logger;
this.mapper = mapper;
this.applicationService = applicationService;
}
@@ -56,8 +52,8 @@ namespace PARR.API.Controllers.V1
if (!string.IsNullOrWhiteSpace(filter.Name))
query = query.Where(t => t.Name.ToLower().Contains(filter.Name.ToLower()));
- if (filter.Type.HasValue)
- query = query.Where(t => t.ApplicationType!.Name == filter.Type.Value.ToString());
+ if (filter.TypeId.HasValue)
+ query = query.Where(t => t.ApplicationTypeId == filter.TypeId);
var apps = await applicationService.GetPage(query, paginationFilter).ToListAsync();
diff --git a/PARR.API/Controllers/V1/ApplicationTypeController.cs b/PARR.API/Controllers/V1/ApplicationTypeController.cs
new file mode 100644
index 00000000..36d6fa74
--- /dev/null
+++ b/PARR.API/Controllers/V1/ApplicationTypeController.cs
@@ -0,0 +1,53 @@
+using AutoMapper;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
+using PARR.API.Contracts.V1;
+using PARR.API.Contracts.V1.Responses;
+using PARR.API.Contracts.V1.Responses.Base;
+using PARR.API.Controllers.V1.Base;
+using PARR.Constants;
+using PARR.DAL.Services.Interfaces;
+
+namespace PARR.API.Controllers.V1
+{
+ ///
+ /// Управление типами приложений
+ ///
+
+ [Authorize(Roles = ParrRoles.Administrator.Role)]
+ public class ApplicationTypeController : BaseApiController
+ {
+ private readonly IMapper mapper;
+ private readonly IApplicationTypeService applicationTypeService;
+
+ public ApplicationTypeController(
+ IMapper mapper,
+ IApplicationTypeService applicationTypeService
+ )
+ {
+ this.mapper = mapper;
+ this.applicationTypeService = applicationTypeService;
+ }
+
+
+ ///
+ /// Список типов приложений
+ ///
+ ///
+ [HttpGet(ApiRoutes.ApplicationType.GetAll)]
+ public async Task GetAll()
+ {
+ var appTypes = await applicationTypeService.Get().OrderBy(t => t.Name)
+ .ToListAsync();
+
+ if (!appTypes.Any())
+ return NoContent();
+
+ var response = mapper.Map>(appTypes);
+
+ return Ok(new Response>(response, true));
+ }
+
+ }
+}