From bd3f21a12c2701ce91d27337ae400fee6f781bb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florin=20Bobi=C8=99?= Date: Sun, 30 Jan 2022 19:07:06 +0200 Subject: [PATCH] added flat structure responses (#4) --- src/CAEN.Functions/Api/SearchCaenCode.cs | 2 +- src/CAEN.Library/Services/CaenService.cs | 7 ++++--- src/CAEN.Library/Services/ICaenService.cs | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/CAEN.Functions/Api/SearchCaenCode.cs b/src/CAEN.Functions/Api/SearchCaenCode.cs index d677540..41dfd08 100644 --- a/src/CAEN.Functions/Api/SearchCaenCode.cs +++ b/src/CAEN.Functions/Api/SearchCaenCode.cs @@ -35,7 +35,7 @@ public async Task Run( } response = req.CreateResponse(HttpStatusCode.OK); - await response.WriteAsJsonAsync>(result); + await response.WriteAsJsonAsync>(result); return response; } diff --git a/src/CAEN.Library/Services/CaenService.cs b/src/CAEN.Library/Services/CaenService.cs index 3c15485..4d8d81b 100644 --- a/src/CAEN.Library/Services/CaenService.cs +++ b/src/CAEN.Library/Services/CaenService.cs @@ -26,11 +26,12 @@ from code in gr.Codes where (sectionId != null ? section.ID.ToLower() == sectionId.ToLower() : true) && (divisionId != null ? division.ID.ToLower() == divisionId.ToLower() : true) && (groupId != null ? gr.ID.ToLower() == groupId.ToLower() : true) - select code).ToList(); + select code) + .Distinct().ToList(); return result; } - public List
SearchCode(string query) + public List SearchCode(string query) { var result = (from section in list from division in section.Divisions @@ -40,7 +41,7 @@ where section.Search(query.ToLower()) || division.Search(query.ToLower()) || gr.Search(query.ToLower()) || code.Search(query.ToLower()) - select section) + select code) .Distinct().ToList(); return result; } diff --git a/src/CAEN.Library/Services/ICaenService.cs b/src/CAEN.Library/Services/ICaenService.cs index 7774588..949406a 100644 --- a/src/CAEN.Library/Services/ICaenService.cs +++ b/src/CAEN.Library/Services/ICaenService.cs @@ -7,6 +7,6 @@ namespace CAEN.Library.Services public interface ICaenService { List GetCodesByFilter(string sectionId = null, string divisionId = null, string groupId = null); - List
SearchCode(string query); + List SearchCode(string query); } }