/// <summary>
        /// Randomize seeds among participants.
        /// </summary>
        /// <param name="tournament"></param>
        /// <returns></returns>
        public IEnumerable<Participant> ParticipantRandomize(Tournament tournament)
        {
            string url = string.Format("tournaments/{0}/participants/randomize", this.TournamentIdentifier(tournament));
            var json = this.MakeJsonRequest(url, WebRequestMethods.Http.Post);

            return Deserializer.ListOfParticipants(json);
        }
        /// <summary>
        /// Remove a participant from a tournament.
        /// </summary>
        /// <param name="tournament"></param>
        /// <param name="participant"></param>
        /// <returns></returns>
        public Participant ParticipantDestroy(Tournament tournament, Participant participant)
        {
            string url = string.Format("tournaments/{0}/participants/{1}", this.TournamentIdentifier(tournament), participant.Id);
            var json = this.MakeJsonRequest(url, "DELETE");

            return Deserializer.Participant(json);
        }
        /// <summary>
        /// Receive a list of all the participants of a tournament.
        /// </summary>
        /// <param name="tournament"></param>
        /// <returns></returns>
        public IList<Participant> ParticipantIndex(Tournament tournament)
        {
            string url = string.Format("tournaments/{0}/participants", this.TournamentIdentifier(tournament));
            var json = this.MakeJsonRequest(url, WebRequestMethods.Http.Get);

            return Deserializer.ListOfParticipants(json);
        }
示例#4
0
        /// <summary>
        /// Fetch a specific match.
        /// </summary>
        /// <param name="tournament"></param>
        /// <param name="matchId"></param>
        /// <returns></returns>
        public Match MatchShow(Tournament tournament, int matchId)
        {
            string url = string.Format("tournaments/{0}/matches/{1}", this.TournamentIdentifier(tournament), matchId);
            var json = this.MakeJsonRequest(url, WebRequestMethods.Http.Get);

            return Deserializer.Match(json);
        }
        public IList<Participant> ParticipantBulkAdd(Tournament tournament, ParticipantBulkAddParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            string url = string.Format("tournaments/{0}/participants/bulk_add", this.TournamentIdentifier(tournament));
            Dictionary<string, dynamic> dictionary = parameters.ToDictionary();

            var response = this.MakeJsonRequest(url, WebRequestMethods.Http.Post, dictionary);
            return Deserializer.ListOfParticipants(response);
        }
示例#6
0
        /// <summary>
        /// List all matches in a tournament.
        /// </summary>
        /// <param name="tournament"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public IList<Match> MatchIndex(Tournament tournament, MatchIndexParameters parameters = null)
        {
            string url = string.Format("tournaments/{0}/matches", this.TournamentIdentifier(tournament));
            var param = new Dictionary<string, dynamic>();
            if (parameters != null)
            {
                param = parameters.ToDictionary();
            }

            var json = this.MakeJsonRequest(url, WebRequestMethods.Http.Get, param);

            return Deserializer.ListOfMatches(json);
        }
        /// <summary>
        /// Add a participant to a tournament.
        /// </summary>
        /// <param name="tournament"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public Participant ParticipantCreate(Tournament tournament, ParticipantCreateParameters parameters = null)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            string url = string.Format("tournaments/{0}/participants", this.TournamentIdentifier(tournament));

            Dictionary<string, dynamic> param = parameters.ToDictionary();
            var json = this.MakeJsonRequest(url, WebRequestMethods.Http.Post, param);

            return Deserializer.Participant(json);
        }
示例#8
0
        /// <summary>
        /// Change some information about the match.
        /// </summary>
        /// <param name="tournament"></param>
        /// <param name="matchId"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public Match MatchUpdate(Tournament tournament, int matchId, MatchUpdateParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            var param = parameters.ToDictionary();

            string url = string.Format("tournaments/{0}/matches/{1}", this.TournamentIdentifier(tournament), matchId);
            var json = this.MakeJsonRequest(url, WebRequestMethods.Http.Put, param);

            return Deserializer.Match(json);
        }
示例#9
0
        public Attachment AttachmentCreate(Tournament tournament, int matchId, AttachmentCreateParameters parameters = null)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            Dictionary<string, dynamic> param = parameters.ToDictionary();

            string url = string.Format("tournaments/{0}/matches/{1}/attachments", this.TournamentIdentifier(tournament), matchId);
            var json = this.MakeJsonRequest(url, WebRequestMethods.Http.Post, param);

            return Deserializer.Attachment(json);
        }
示例#10
0
 public Attachment AttachmentDelete(Tournament tournament, int matchId, int attachmentId)
 {
     throw new NotImplementedException();
 }
示例#11
0
 public Attachment AttachmentShow(Tournament tournament, int matchId, int attachmentId)
 {
     throw new NotImplementedException();
 }
示例#12
0
 /// <summary>
 /// Deletes a tournament along with all its associated records. There is no undo, so use with care!
 /// </summary>
 /// <returns></returns>
 public Tournament TournamentDestroy(Tournament tournament)
 {
     string url = string.Format("tournaments/{0}", this.TournamentIdentifier(tournament));
     var json = this.MakeJsonRequest(url, "DELETE");
     return Deserializer.Tournament(json);
 }
示例#13
0
 /// <summary>
 /// Extract the identifier from a Tournament.
 /// </summary>
 /// <param name="tournament"></param>
 /// <returns></returns>
 private string TournamentIdentifier(Tournament tournament)
 {
     return string.IsNullOrWhiteSpace(tournament.Subdomain)
         ? tournament.Id.ToString(CultureInfo.InvariantCulture)
         : string.Format("{0}-{1}", tournament.Subdomain, tournament.Url);
 }
示例#14
0
        /// <summary>
        /// Update a tournament's attributes.
        /// </summary>
        /// <returns></returns>
        public Tournament TournamentUpdate(Tournament tournament, TournamentUpdateParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            Dictionary<string, dynamic> param = parameters.ToDictionary();

            if (param.Count == 0)
            {
                throw new ArgumentException("You need to change some parameters in order to call update.", "parameters");
            }

            string url = string.Format("tournaments/{0}", this.TournamentIdentifier(tournament));
            var json = this.MakeJsonRequest(url, WebRequestMethods.Http.Put, param);
            return Deserializer.Tournament(json);
        }
示例#15
0
 public Attachment AttachmentIndex(Tournament tournament, int matchId)
 {
     throw new NotImplementedException();
 }
示例#16
0
        /// <summary>
        /// Fetch a specific participant.
        /// </summary>
        /// <param name="tournament"></param>
        /// <param name="participantId"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public Participant ParticipantShow(Tournament tournament, int participantId, ParticipantShowParameters parameters = null)
        {
            string url = string.Format("tournaments/{0}/participants/{1}", this.TournamentIdentifier(tournament), participantId);
            var param = new Dictionary<string, dynamic>();
            if (parameters != null)
            {
                param = parameters.ToDictionary();
            }

            var json = this.MakeJsonRequest(url, WebRequestMethods.Http.Get, param);
            return Deserializer.Participant(json);
        }
示例#17
0
 /// <summary>
 /// Finalize a tournament, rendering its results permanent.
 /// </summary>
 /// <returns></returns>
 public Tournament TournamentFinalize(Tournament tournament)
 {
     string url = string.Format("tournaments/{0}/finalize", this.TournamentIdentifier(tournament));
     var json = this.MakeJsonRequest(url, WebRequestMethods.Http.Post);
     return Deserializer.Tournament(json);
 }
示例#18
0
        /// <summary>
        /// Reset a tournament, clearing all of its scores and attachments. 
        /// You can then add/remove/edit participants before starting the tournament again (tournaments/start).
        /// 
        /// Discovery:
        ///     It does not clear for participants.
        /// </summary>
        /// <returns></returns>
        public Tournament TournamentReset(Tournament tournament, TournamentResetParameters parameters = null)
        {
            string url = string.Format("tournaments/{0}/reset", this.TournamentIdentifier(tournament));
            var param = new Dictionary<string, dynamic>();
            if (parameters != null)
            {
                param = parameters.ToDictionary();
            }

            var json = this.MakeJsonRequest(url, WebRequestMethods.Http.Post, param);

            return Deserializer.Tournament(json);
        }
示例#19
0
 public Attachment AttachmentUpdate(Tournament tournament, int matchId, AttachmentUpdateParameters parameters = null)
 {
     throw new NotImplementedException();
 }
示例#20
0
 public Attachment AttachmentUpdate(Tournament tournament, int matchId, AttachmentUpdateParameters parameters = null)
 {
     throw new NotImplementedException();
 }