public string AddRiderToRace(string raceName, string riderName) { IRace race = this.raceRepository .GetByName(raceName); if (race == null) { throw new InvalidOperationException( string.Format( ExceptionMessages.RaceNotFound, raceName)); } IRider rider = this.riderRepository .GetByName(riderName); if (rider == null) { throw new InvalidOperationException( string.Format( ExceptionMessages.RiderNotFound, riderName)); } race.AddRider(rider); return(string.Format( OutputMessages.RiderAdded, riderName, raceName)); }
public string AddRiderToRace(string raceName, string riderName) { IRace race = CheckIfRaceExists(raceName); IRider rider = CheckIfRiderExists(riderName); race.AddRider(rider); return(string.Format(OutputMessages.RiderAdded, riderName, raceName)); }
public string AddRiderToRace(string raceName, string riderName) { IRace race = races.GetByName(raceName); IRider rider = riders.GetByName(riderName); race.AddRider(rider); return(string.Format(OutputMessages.RiderAdded, rider.Name, race.Name)); } // TODO: Repair
public string AddRiderToRace(string raceName, string riderName) { IRace race = raceRepository.GetByName(raceName); IRider rider = riderRepository.GetByName(riderName); race.AddRider(rider); return($"{string.Format(OutputMessages.RiderAdded, riderName, raceName)}"); }
public string AddRiderToRace(string raceName, string riderName) { if ((raceRepository.Models.FirstOrDefault(r => r.Name == raceName)) == null) { throw new InvalidOperationException(String.Format(ExceptionMessages.RaceNotFound, raceName)); } if (riderRepository.Models.FirstOrDefault(r => r.Name == riderName) == null) { throw new InvalidOperationException(String.Format(ExceptionMessages.RiderNotFound, riderName)); } IRider rider = riderRepository.Models.FirstOrDefault(r => r.Name == riderName); IRace race = raceRepository.Models.FirstOrDefault(r => r.Name == raceName); race.AddRider(rider); return(String.Format(OutputMessages.RiderAdded, rider.Name, race.Name)); }
public string AddRiderToRace(string raceName, string riderName) { IRace race = raceRepository.GetByName(raceName); if (race == null) { throw new InvalidOperationException($"Race {raceName} could not be found."); } IRider rider = riderRepository.GetByName(riderName); if (rider == null) { throw new InvalidOperationException($"Rider {riderName} could not be found."); } race.AddRider(rider); return($"Rider {riderName} added in {raceName} race."); }
public string AddRiderToRace(string raceName, string riderName) { //Adds a rider to the race. IRace race = this.raceRepository .GetByName(raceName); //If the race does not exist in the race repository, throw an InvalidOperationException with message: //• "Race {name} could not be found." if (race == null) { throw new InvalidOperationException( string.Format( ExceptionMessages.RaceNotFound, raceName)); } //If the rider does not exist in the rider repository, throw an InvalidOperationException with message: //• "Rider {name} could not be found." IRider rider = this.riderRepository .GetByName(riderName); if (rider == null) { throw new InvalidOperationException( string.Format( ExceptionMessages.RiderNotFound, riderName)); } //If everything is successful, you should add the rider to the race and return the following message: race.AddRider(rider); string result = string.Format( OutputMessages.RiderAdded, riderName, raceName); return(result); }
public string AddRiderToRace(string raceName, string riderName) { IRace race = this.races.GetByName(raceName); IRider rider = this.riders.GetByName(riderName); if (race == null) { throw new InvalidOperationException($"Race {raceName} could not be found."); } else if (rider == null) { throw new InvalidOperationException($"Rider {riderName} could not be found."); } else { race.AddRider(rider); return($"Rider {rider.Name} added in {race.Name} race."); } }
public string AddRiderToRace(string raceName, string riderName) { if (races.GetAll().All(r => r.Name != raceName)) { throw new InvalidOperationException(String.Format(ExceptionMessages.RaceNotFound, raceName)); } if (riders.GetAll().All(r => r.Name != riderName)) { throw new InvalidOperationException(String.Format(ExceptionMessages.RiderNotFound, riderName)); } IRider rider = riders.GetAll().First(r => r.Name == riderName); IRace race = races.GetAll().First(r => r.Name == raceName); race.AddRider(rider); return(String.Format(OutputMessages.RiderAdded, riderName, raceName)); }
public string AddRiderToRace(string raceName, string riderName) { bool isExistRace = this.raceRepository .GetAll() .Any(r => r.Name == raceName); if (!isExistRace) { throw new InvalidOperationException( string.Format( ExceptionMessages.RaceNotFound, raceName)); } bool isExistRider = this.riderRepository .GetAll() .Any(r => r.Name == riderName); if (!isExistRider) { throw new InvalidOperationException( string.Format( ExceptionMessages.RiderNotFound, riderName)); } IRider rider = this.riderRepository .GetByName(riderName); IRace race = this.raceRepository .GetByName(raceName); race.AddRider(rider); string result = string.Format( OutputMessages.RiderAdded, riderName, raceName); return(result); }
public string AddRiderToRace(string raceName, string riderName) { if (this.raceRepository.GetByName(raceName) == null) { string result = string.Format(ExceptionMessages.RaceNotFound, raceName); throw new InvalidOperationException(result); } if (this.riderRepository.GetByName(riderName) == null) { string result = string.Format(ExceptionMessages.RiderNotFound, riderName); throw new InvalidOperationException(result); } IRace race = this.raceRepository.GetByName(raceName); IRider rider = this.riderRepository.GetByName(riderName); race.AddRider(rider); string output = string.Format(OutputMessages.RiderAdded, riderName, raceName); return(output); }