feat(api): ResponseAreaController getAll. WorkGroupController, getAll, добавлен фильтр по ЗО.

This commit is contained in:
Mikhail Trubnikov
2024-08-16 13:59:27 +10:00
parent 0f3def4b3a
commit ecd24cd94b
7 changed files with 105 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using PARR.API.Extensions;
using PARR.Constants;
using PARR.DAL.Contracts;
using PARR.DAL.DomainModels;
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces;
@@ -50,6 +51,15 @@ namespace PARR.API.Controllers.V1
if (!string.IsNullOrEmpty(filter.Name))
query = query.Where(t => t.Name.ToLower().Contains(filter.Name.ToLower()));
if (filter.ResponseAreaCode.HasValue)
{
//todo: validate ResponseAreaEnum
if (!Enum.IsDefined(typeof(ResponseAreaEnum), filter.ResponseAreaCode.Value))
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { FieldName = nameof(filter.ResponseAreaCode), Message = "Неверное значение" } }));
query = query.Where(t => t.ResponseAreaCode == filter.ResponseAreaCode.Value);
}
var workGroups = await workGroupService.GetPage(query, paginationFilter).ToListAsync();
if (!workGroups.Any())