static void Main(string[] args) { // prepare the client for access apiClient = new Client("guest", "guest", WdsfEndpoint.Sandbox); Console.Write("Enter competition ID:"); int competitionId; if (!int.TryParse(Console.ReadLine(), out competitionId)) { Console.WriteLine("Not a valid competition ID"); Console.ReadKey(); return; } CompetitionDetail competition = apiClient.GetCompetition(competitionId); Console.WriteLine( "Registering for competition {0} {1} {2} in {3}-{4} on {5}", competition.CompetitionType, competition.AgeClass, competition.Discipline, competition.Location, competition.Country, competition.Date); // prepare the person filter Dictionary <string, string> personFilter = new Dictionary <string, string>() { { FilterNames.Person.NameOrMin, string.Empty }, { FilterNames.Person.Type, "Adjudicator,Chairman" } }; do { // ask for an official name and list all possible matches ListPersons(personFilter); // choose one officials from the list PersonDetail selectedPerson = ChoosePerson(); // and save the person as a new official Uri newOfficialUri = SavePerson(competition, selectedPerson); if (newOfficialUri != null) { // get the newly created official to display it OfficialDetail official = apiClient.Get <OfficialDetail>(newOfficialUri); Console.WriteLine("Added official '{0}' to competition with ID:{1}.", official.Person, official.Id); } Console.Write("Add more? [Y]es/[N]o :"); } while (Console.ReadKey().Key == ConsoleKey.Y); // show all registered officials of this competition ListAllOfficials(competition); Console.ReadKey(); }
public Uri SaveOfficial(OfficialDetail official) { if (official == null) { throw new ArgumentNullException("official"); } return(SaveResource <OfficialDetail>(official, "official")); }
public bool UpdateOfficial(OfficialDetail official) { if (official == null) { throw new ArgumentNullException("official"); } return(UpdateResource <OfficialDetail>(official, string.Format("official/{0}", official.Id))); }
///<inheritdoc/> public bool UpdateOfficial(OfficialDetail official) { if (official == null) { throw new ArgumentNullException(nameof(official)); } return(UpdateResource(official, "official/" + official.Id)); }
private static Uri SavePerson(CompetitionDetail competition, PersonDetail selectedPerson) { Uri newOfficialUri = null; do { Console.Write("Enter adjudicator char or [nothing] for Chairman: "); string adjudicatorChar = Console.ReadLine(); OfficialDetail official = new OfficialDetail() { CompetitionId = competition.Id, Min = selectedPerson.Min }; if (adjudicatorChar == string.Empty || adjudicatorChar.Contains("nothing")) { official.Task = "Chairman"; } else { official.Task = "Adjudicator"; official.AdjudicatorChar = adjudicatorChar; } try { newOfficialUri = apiClient.SaveOfficial(official); } catch (ApiException ex) { Console.WriteLine(ex.InnerException.Message); return(null); } } while (false); return(newOfficialUri); }