コード例 #1
0
ファイル: TeamsManager.cs プロジェクト: omidmokhtari93/OWM
        public async Task <bool> CanJoinTeam(int teamId, int profileId)
        {
            var team = await _teamService.Queryable()
                       .Include(x => x.AllowedOccupations)
                       .SingleAsync(x => x.Id == teamId);

            if (team.IsClosed)
            {
                return(false);
            }

            if (await IsMemberOfTeam(teamId, profileId))
            {
                return(false);
            }


            if (!team.OccupationFilter)
            {
                return(true);
            }

            IUserInformationService uInfoSrvc = new UserInformationService(_profileService);
            var profileOccupation             = await uInfoSrvc.GetUserOccupationAsync(profileId);

            return(team.AllowedOccupations.Any(x => x.OccupationId == profileOccupation.Id));
        }
コード例 #2
0
ファイル: TeamsManager.cs プロジェクト: omidmokhtari93/OWM
        public async Task <ProfileInformationDto> GetTeamMemberProfileInformation(int profileId)
        {
            IUserInformationService uInfoSrvc = new UserInformationService(_profileService);
            var profileInfo = await uInfoSrvc.GetUserProfileInformationAsync(profileId);

            var myTeams = await GetListOfMyTeams(profileId);

            return(new ProfileInformationDto
            {
                ProfilePicture = profileInfo.ProfilePicture,
                Country = profileInfo.CountryName,
                City = profileInfo.CityName,
                Surname = profileInfo.Surname,
                FirstName = profileInfo.Name,
                Occupation = profileInfo.Occupation,
                Interests = profileInfo.Interests.Select(x => x.Name).ToList(),
                MilesCompleted = profileInfo.MilesCompleted,
                MilesPledged = profileInfo.MilesPledged,
                TeamsCreated = myTeams.Where(x => x.IsCreator).Select(x => new TeamInfoDto()
                {
                    TeamName = x.TeamName,
                    Id = x.TeamId
                }).ToList(),
                TeamsJoined = myTeams.Where(x => !x.IsCreator).Select(x => new TeamInfoDto()
                {
                    TeamName = x.TeamName,
                    Id = x.TeamId
                }).ToList()
            });
        }