Exemplo n.º 1
0
        /// <summary>
        /// Initializes the specified view model.
        /// </summary>
        /// <param name="viewModel">The view model.</param>
        public void Init(MyTournamentsSignInViewModel viewModel)
        {
            this.BindingContext = viewModel;

            this.HomeButton.Clicked   += this.HomeButton_Clicked;
            this.SignInButton.Clicked += this.SignInButton_Clicked;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MyTournamentsPresenter" /> class.
 /// </summary>
 /// <param name="myTournamentsPage">My tournaments page.</param>
 /// <param name="myTournamentSignInPage">My tournament sign in page.</param>
 /// <param name="myTournamentsViewModel">My tournaments view model.</param>
 /// <param name="myTournamentsSignInViewModel">My tournaments sign in view model.</param>
 /// <param name="apiClient">The API client.</param>
 public MyTournamentsPresenter(IMyTournamentsPage myTournamentsPage,
                               IMyTournamentSignInPage myTournamentSignInPage,
                               MyTournamentsViewModel myTournamentsViewModel,
                               MyTournamentsSignInViewModel myTournamentsSignInViewModel,
                               IClient apiClient)
 {
     this.MyTournamentsViewModel       = myTournamentsViewModel;
     this.MyTournamentsSignInViewModel = myTournamentsSignInViewModel;
     this.MyTournamentsPage            = myTournamentsPage;
     this.MyTournamentSignInPage       = myTournamentSignInPage;
     this.ApiClient = apiClient;
 }
        /// <summary>
        /// Gets the next available tournaments for sign in.
        /// </summary>
        /// <param name="passwordToken">The password token.</param>
        /// <param name="playerId">The player identifier.</param>
        /// <param name="viewModel">The view model.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        public async Task GetNextAvailableTournamentsForSignIn(String passwordToken,
                                                               Guid playerId,
                                                               MyTournamentsSignInViewModel viewModel,
                                                               CancellationToken cancellationToken)
        {
            // Get memberships
            List <ClubMembershipResponse> memberships = await this.PlayerClient.GetPlayerMemberships(passwordToken, playerId, cancellationToken);

            List <GetTournamentResponse> tournaments = new List <GetTournamentResponse>();

            // Get Tournaments
            foreach (ClubMembershipResponse clubMembershipResponse in memberships)
            {
                GetTournamentListResponse tournamentsForClub =
                    await this.TournamentClient.GetTournamentList(passwordToken, clubMembershipResponse.GolfClubId, cancellationToken);

                tournaments.AddRange(tournamentsForClub.Tournaments);
            }

            // Get First one (Need to decide how to actually sort these....)
            IEnumerable <GetTournamentResponse> availableTournaments = tournaments.Where(t => t.HasBeenCompleted == false && t.TournamentDate.Date == DateTime.Today);

            foreach (GetTournamentResponse getTournamentResponse in availableTournaments)
            {
                if (viewModel.Tournaments == null)
                {
                    viewModel.Tournaments = new ObservableCollection <TournamentSignInViewModel>();
                }

                viewModel.Tournaments.Add(new TournamentSignInViewModel
                {
                    TournamentId   = getTournamentResponse.TournamentId,
                    CourseName     = getTournamentResponse.MeasuredCourseName,
                    TournamentName = getTournamentResponse.TournamentName,
                    TournamentDate = getTournamentResponse.TournamentDate,
                    Format         = getTournamentResponse.TournamentFormat.ToString()
                });
            }
        }