Esempio n. 1
0
        public Task <TeamDTO> GetTeamByIdAsync(long targetTeamId, CancellationTokenSource cancellationTokenSource) =>
        Task <TeamDTO> .Run(async() => {
            if (!CrossConnectivity.Current.IsConnected)
            {
                throw new InvalidOperationException(AppConsts.ERROR_INTERNET_CONNECTION);
            }

            TeamDTO team = null;

            GetTeamByIdRequest getTeamByIdRequest = new GetTeamByIdRequest()
            {
                AccessToken = GlobalSettings.Instance.UserProfile.AccesToken,
                Url         = string.Format(GlobalSettings.Instance.Endpoints.TeamEndPoints.GetTeamById, targetTeamId)
            };

            GetTeamByIdResponse getTeamByIdResponse = null;

            try {
                getTeamByIdResponse = await _requestProvider.GetAsync <GetTeamByIdRequest, GetTeamByIdResponse>(getTeamByIdRequest);

                if (getTeamByIdResponse == null)
                {
                    throw new InvalidOperationException(CANT_GET_TEAM_ERROR);
                }

                team = _teamFactory.BuildTeam(getTeamByIdResponse);
            }
            catch (Exception exc) {
                Crashes.TrackError(exc);
                throw;
            }

            return(team);
        }, cancellationTokenSource.Token);
Esempio n. 2
0
        public GetTeamByIdResponse GetTeamById(GetTeamByIdRequest request)
        {
            var response    = new GetTeamByIdResponse();
            var teamDetails = uow.Repository <TeamEntity>().GetDetails(x => x.TeamId == request.TeamId);

            response.Team = new Team
            {
                TeamName = teamDetails.TeamName,
                TeamId   = teamDetails.TeamId
            };
            var dbUsers         = uow.Repository <UserEntity>().GetOverview();
            var dbTeams         = uow.Repository <TeamEntity>().GetOverview();
            var dbXrefUsersTeam = uow.Repository <XrefUserTeamEntity>().GetOverview();
            var dbRoles         = uow.Repository <RolesEntity>().GetOverview();

            var result = (from team in dbTeams
                          join xref in dbXrefUsersTeam on team.TeamId equals xref.TeamId
                          join user in dbUsers on xref.UserId equals user.UserId
                          join role in dbRoles on user.RoleId equals role.RoleId
                          where team.TeamId == request.TeamId
                          select new Member
            {
                UserId = user.UserId,
                UserName = user.Username,
                UserRole = role.RoleName
            }
                          );

            response.Members = result;
            return(response);
        }
Esempio n. 3
0
        public TeamDTO BuildTeam(GetTeamByIdResponse data)
        {
            TeamDTO teamDTO = null;

            if (data != null)
            {
                teamDTO = new TeamDTO()
                {
                    Coach          = data.Coach,
                    CoachId        = data.CoachId,
                    CreatedBy      = data.CreatedBy,
                    Events         = data.Events,
                    Games          = data.Games,
                    Id             = data.Id,
                    Locations      = data.Locations,
                    Members        = data.Members,
                    Name           = data.Name,
                    Opponents      = data.Opponents,
                    Organization   = data.Organization,
                    OrganizationId = data.OrganizationId,
                    Owner          = data.Owner,
                    Sport          = data.Sport
                };
            }

            return(teamDTO);
        }
Esempio n. 4
0
        public void Handle(GetTeamByIdRequest request)
        {
            try
            {
                var config = new AutoMapper.MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <Team, GetTeamItem>();
                });

                var mapper = config.CreateMapper();

                var player = mapper.Map <GetTeamItem>(_teamRepo.Get(request.Id));

                var response = new GetTeamByIdResponse(player);
                Sender.Tell(response);

                _logger.Info("Get Team by Id: {0}", request.Id);
            }
            catch (Exception ex)
            {
                _logger.Error("Could't get Team by id: {0} : {1}", request.Id, ex.Message);
                throw;
            }
        }