private List <Ability> FilterAbilites(List <Ability> abilities, AbilityQuery query) { if (query == null) { return(abilities); } if (query.Id != null) { abilities = abilities.Where(x => query.Id.IndexOf(x.Id) >= 0).ToList(); } if (query.Name != null) { abilities = abilities.Where(x => query.Name.Where(y => x.Name.ToLower() .Contains(y.ToLower() ) ).Count() > 0) .ToList(); } return(abilities); }
public async Task <List <Ability> > GetAbilities(AbilityQuery query) { var content = await RepositoryParser.ParseRepository <List <Ability> >(filePaths.Abilities); var queryedItems = FilterAbilites(content, query); return(queryedItems); }
public async Task <IActionResult> GetAbilities([FromQuery] AbilityQuery query) { try { return(Ok(await abilitiesService.GetAbilities(query))); } catch (FileNotFoundException ex) { return(BadRequest(ex)); } catch (Exception ex) { return(BadRequest(ex)); } }