private async Task LoadContextAsync(int?teamId, int?eventId) { Me = meProvider.Me; MyTeams = Me.Membership.Select(x => x.Team).ToList() ?? new List <Team>(); Event = await eventRepo.GetEventAsync(eventId); if (Event == null) { Team = meProvider.GetTeam(teamId); Event = Team?.Event.OrderBy(x => x.Date).FirstOrDefault(x => x.Date > DateTime.Now); } else { Team = meProvider.GetTeam(Event.TeamId); if (Team?.Id != Event.TeamId) { Event = null; } } Membership = Me.Membership.FirstOrDefault(x => x.TeamId == Team?.Id); Participation = Event?.Participation.FirstOrDefault(x => x.PersonId == Me.Id); NextEvents = Team.Event .OrderBy(x => x.Date) .Where(x => !x.Special && x.Date > DateTime.Now.AddHours(-1) && x.Id != Event?.Id) .Take(5) .ToList(); SpecialEvents = Team.Event .OrderBy(x => x.Date) .Where(x => x.Special && x.Date > DateTime.Now.AddHours(-1) && x.Id != Event?.Id) .ToList(); Posts = Team.Post.TakeLast(50).OrderByDescending(x => x.Id).ToList(); if (Posts.Count > 0 && Posts[0].PersonId == Me?.Id) { MyLastPost = Posts[0]; } }
public Team GetManagedTeam(int?teamId) { return(meProvider.GetTeam(teamId)); }