Skip to content

Commit

Permalink
added flat structure responses (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
twentytwokhz authored Jan 30, 2022
1 parent 99749a3 commit bd3f21a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/CAEN.Functions/Api/SearchCaenCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<HttpResponseData> Run(
}

response = req.CreateResponse(HttpStatusCode.OK);
await response.WriteAsJsonAsync<List<Section>>(result);
await response.WriteAsJsonAsync<List<CaenCode>>(result);

return response;
}
Expand Down
7 changes: 4 additions & 3 deletions src/CAEN.Library/Services/CaenService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Section> SearchCode(string query)
public List<CaenCode> SearchCode(string query)
{
var result = (from section in list
from division in section.Divisions
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/CAEN.Library/Services/ICaenService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ namespace CAEN.Library.Services
public interface ICaenService
{
List<CaenCode> GetCodesByFilter(string sectionId = null, string divisionId = null, string groupId = null);
List<Section> SearchCode(string query);
List<CaenCode> SearchCode(string query);
}
}

0 comments on commit bd3f21a

Please sign in to comment.