コード例 #1
0
        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);
        }
コード例 #2
0
        public async Task <List <Ability> > GetAbilities(AbilityQuery query)
        {
            var content = await RepositoryParser.ParseRepository <List <Ability> >(filePaths.Abilities);

            var queryedItems = FilterAbilites(content, query);

            return(queryedItems);
        }
コード例 #3
0
 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));
     }
 }