Beispiel #1
0
        public async Task <List <Path> > GetPathsByProperty(PathSearch locationSearch)
        {
            Path path = new Path();

            PropertyInfo info = path
                                .GetType()
                                .GetProperty(locationSearch.searchByProperty.ToString());
            PropertyInfo info1 = locationSearch
                                 .GetType()
                                 .GetProperty(locationSearch.searchByProperty.ToString());

            List <Path> pathsInPropery = await _dbcontext.Paths.ToListAsync();

            if (pathsInPropery == null)
            {
                //  Log.Warning("Couldn't find any paths");
                throw new Exception("NotFound:Couldn't find any paths");
            }
            List <Path> newPathsInPropery = new List <Path>();

            for (int i = 0; i < pathsInPropery.Count(); i++)
            {
                if (string.Compare(info.GetValue(pathsInPropery[i]).ToString(), info1.GetValue(locationSearch).ToString()) == 0)
                {
                    newPathsInPropery.Add(pathsInPropery[i]);
                }
            }


            if (newPathsInPropery == null)
            {
                //  Log.Warning("Couldn't find any paths in property {@pathSearchByCity}", locationSearch.searchByProperty);
                throw new Exception($"NotFound:Couldn't find any paths for property {locationSearch.searchByProperty}");
            }
            return(newPathsInPropery);
        }