DotNetClub.Core.Service.CategoryService.All C# (CSharp) Method

All() public method

public All ( ) : List
return List
        public List<CategoryModel> All()
        {
            var categorySections = this.Configuration.GetSection("Categories").GetChildren();

            List<CategoryModel> categoryList = new List<CategoryModel>();

            foreach (var section in categorySections)
            {
                var category = new CategoryModel
                {
                    Key = section["Key"],
                    Name = section["Name"]
                };
                categoryList.Add(category);
            }

            return categoryList;
        }