Пример #1
0
        public List <Club> GetClubs(int rootId)
        {
            List <Club> res   = new List <Club>();
            var         clubs = cs.GetChildren(rootId);


            foreach (var club in clubs)
            {
                List <Team> teams = tc.GetTeams(club.Id);

                var c = new Club
                {
                    Id          = club.Id,
                    Name        = club.Properties["clubTitle"].Value.ToString(),
                    Description = club.Properties["clubDescription"].Value.ToString(),
                    Teams       = teams
                };

                try
                {
                    string guid    = club.Properties["clubLogo"].Value.ToString();
                    var    udi     = Udi.Parse(guid);
                    var    media   = Umbraco.GetIdForUdi(udi);
                    var    content = Umbraco.Media(media);
                    var    imgPath = content.Url;
                    c.ClubLogo = imgPath;
                }
                catch (NullReferenceException e)
                {
                    Console.WriteLine(e.Message);
                }

                res.Add(c);
            }

            return(res);
        }
Пример #2
0
        public List <Club> GetAllClubs(int id)
        {
            var         cs       = Services.ContentService;
            List <Club> allClubs = new List <Club>();
            var         clubs    = cs.GetChildren(id);
            var         tc       = new TeamController();

            foreach (var club in clubs)
            {
                List <Team> teams = tc.GetTeams(club.Id);

                var c = new Club
                {
                    Id          = club.Id,
                    Name        = club.Properties["clubTitle"].Value.ToString(),
                    Description = club.Properties["clubDescription"].Value.ToString(),
                    Teams       = teams
                };
                allClubs.Add(c);
            }

            return(allClubs);
        }