コード例 #1
0
        public List <TeamMenuItem> GetTeamsList()
        {
            var teamsList = db.Teams
                            .ToList();

            var teamMenu = new List <TeamMenuItem>();

            foreach (var team in teamsList)
            {
                var teamMenuItem = new TeamMenuItem()
                {
                    TeamId   = team.Id,
                    TeamName = team.Name
                };

                teamMenu.Add(teamMenuItem);
            }

            return(teamMenu);
        }
コード例 #2
0
        public List <TeamMenuItem> GetUserTeamsList(User user)
        {
            var userTeamsList = db.Teams
                                .Where(t => t.Users.Select(u => u.Id).Contains(user.Id))
                                .ToList();

            var teamMenu = new List <TeamMenuItem>();

            foreach (var team in userTeamsList)
            {
                var teamMenuItem = new TeamMenuItem()
                {
                    TeamId   = team.Id,
                    TeamName = team.Name
                };

                teamMenu.Add(teamMenuItem);
            }

            return(teamMenu);
        }