Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added flat structure responses #4

Merged
merged 1 commit into from
Jan 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}