private void UserOpenDetail(UserOpenDetailMessage userOpenDetailMessage) { try { if (User == null) { User = _userRepository.GetById(userOpenDetailMessage.UserId); } } catch { Console.Out.WriteLine("User does not exist!"); } try { SetupActivitiesProperties(); } catch { Console.Out.WriteLine("Loading activities error"); } try { TeamListItems.Clear(); var teams = _teamRepository.GetAllByUserId(User.Id); TeamListItems.AddRange(teams); } catch { Console.Out.WriteLine("Loading teams error"); } }
public IEnumerable <TeamListItems> GetTeams() { using (var ctx = new ApplicationDbContext()) { var collection = new List <TeamListItems>(); foreach (var item in ctx.Teams) { var newTeamListItems = new TeamListItems { Name = item.Name, TeamId = item.TeamId }; collection.Add(newTeamListItems); } return(collection); } }