public string AddDriverToRace(string raceName, string driverName) { IRace race = raceRepository.GetByName(raceName); IDriver driver = driverRepository.GetByName(driverName); race.AddDriver(driver); return(String.Format(OutputMessages.DriverAdded, driverName, raceName)); }
public string AddDriverToRace(string raceName, string driverName) { IDriver driver = DriverRepository.Colection.FirstOrDefault(el => el.Name == driverName); IRace race = RaceRepository.Colection.FirstOrDefault(el => el.Name == raceName); if (race == null) { throw new InvalidOperationException(string.Format(ExceptionMessages.RaceNotFound, raceName)); } if (driver == null) { throw new InvalidOperationException(string.Format(ExceptionMessages.DriverNotFound, driverName)); } race.AddDriver(driver); return(string.Format(OutputMessages.DriverAdded, driverName, raceName)); }
public string AddDriverToRace(string raceName, string driverName) { IRace currentRace = raceRep.GetByName(raceName); IDriver currentDriver = driveRep.GetByName(driverName); if (currentRace == null) { throw new InvalidOperationException($"Race {raceName} could not be found."); } if (currentDriver == null) { throw new InvalidOperationException($"Driver {driverName} could not be found."); } currentRace.AddDriver(currentDriver); return($"Driver {driverName} added in {raceName} race."); }
public string AddDriverToRace(string raceName, string driverName) { IRace race = raceRepository.GetByName(raceName); if (race is null) { throw new InvalidOperationException(string.Format(ExceptionMessages.RaceNotFound, raceName)); } IDriver driver = driverRepository.GetByName(driverName); if (driver is null) { throw new InvalidOperationException(string.Format(ExceptionMessages.DriverNotFound, driverName)); } race.AddDriver(driver); return(string.Format(OutputMessages.DriverAdded, driverName, raceName)); }
public string AddDriverToRace(string raceName, string driverName) { IRace race = raceRepository.GetByName(raceName); IDriver driver = driversRepository.GetByName(driverName); if (race == null) { throw new InvalidOperationException($"Race {raceName} could not be found."); } else if (driver == null) { throw new InvalidOperationException($"Driver { driverName } could not be found."); } race.AddDriver(driver); return($"Driver {driverName} added in {raceName} race."); }
public string AddDriverToRace(string raceName, string driverName) { if (this.raceRepository.GetByName(raceName) == null) { throw new InvalidOperationException($"Race {raceName} could not be found."); } if (this.driverRepository.GetByName(driverName) == null) { throw new InvalidOperationException($"Driver {driverName} could not be found."); } IDriver driver = this.driverRepository.GetByName(driverName); IRace race = this.raceRepository.GetByName(raceName); race.AddDriver(driver); return(string.Format(OutputMessages.DriverAdded, driverName, raceName)); }
public string AddDriverToRace(string raceName, string driverName) { IRace raceFromRepository = raceRepository.GetAll().FirstOrDefault(x => x.Name == raceName); if (raceFromRepository == null) { throw new InvalidOperationException(String.Format(ExceptionMessages.RaceNotFound, raceName)); } IDriver driverFromRepository = driverRepository.GetAll().FirstOrDefault(x => x.Name == driverName); if (driverFromRepository == null) { throw new InvalidOperationException(String.Format(ExceptionMessages.DriverNotFound, driverName)); } raceFromRepository.AddDriver(driverFromRepository); return(String.Format(OutputMessages.DriverAdded, driverName, raceName)); }
public string AddDriverToRace(string raceName, string driverName) { if (!this.driverRepository.GetAll().Any(d => d.Name == driverName)) { throw new InvalidOperationException(string.Format(ExceptionMessages.DriverNotFound, driverName)); } IDriver driver = this.driverRepository.GetByName(driverName); if (!this.raceRepository.GetAll().Any(r => r.Name == raceName)) { throw new InvalidOperationException(String.Format(ExceptionMessages.RaceNotFound, raceName)); } IRace race = this.raceRepository.GetByName(raceName); race.AddDriver(driver); var msg = String.Format(OutputMessages.DriverAdded, driverName, raceName); return(msg); }
public string AddDriverToRace(string raceName, string driverName) { IDriver driver = this.drivers.GetByName(driverName); IRace race = this.races.GetByName(raceName); if (race == null) { string msg1 = String.Format(ExceptionMessages.RaceNotFound, raceName); throw new InvalidOperationException(msg1); } if (driver == null) { string msg1 = String.Format(ExceptionMessages.DriverNotFound, driverName); throw new InvalidOperationException(msg1); } race.AddDriver(driver); string msg = String.Format(OutputMessages.DriverAdded, driverName, raceName); return(msg); }
public string AddDriverToRace(string raceName, string driverName) { if (!races.Any(x => x.Name == raceName)) { string exeption = string.Format(ExceptionMessages.RaceNotFound, raceName); throw new InvalidOperationException(exeption); } if (!drivers.Any(x => x.Name == driverName)) { string exeption = string.Format(ExceptionMessages.DriverNotFound, driverName); throw new InvalidOperationException(exeption); } IDriver driver = drivers.FirstOrDefault(x => x.Name == driverName); IRace race = races.FirstOrDefault(x => x.Name == raceName); race.AddDriver(driver); return(string.Format(OutputMessages.DriverAdded, driverName, raceName)); }
public string AddDriverToRace(string raceName, string driverName) { if (!this.raceRepository.GetAll().Any(x => x.Name == raceName)) { string err = string.Format(ExceptionMessages.RaceNotFound, raceName); throw new InvalidOperationException(err); } if (!this.driverRepository.GetAll().Any(x => x.Name == driverName)) { string err = string.Format(ExceptionMessages.DriverNotFound, driverName); throw new InvalidOperationException(err); } IRace race = this.raceRepository.GetAll().FirstOrDefault(r => r.Name == raceName); IDriver driver = this.driverRepository.GetAll().FirstOrDefault(d => d.Name == driverName); race.AddDriver(driver); string message = string.Format(OutputMessages.DriverAdded, driverName, raceName); return(message); }
public string AddDriverToRace(string raceName, string driverName) { IRace race = races.GetAll().FirstOrDefault(x => x.Name == raceName); IDriver driver = drivers.GetAll().FirstOrDefault(x => x.Name == driverName); if (race == null) { string msg = string.Format(ExceptionMessages.RaceNotFound, raceName); throw new InvalidOperationException(msg); } if (driver == null) { string msg = string.Format(ExceptionMessages.DriverNotFound, driverName); throw new InvalidOperationException(msg); } race.AddDriver(driver); string outputMsg = string.Format(OutputMessages.DriverAdded, driverName, raceName); return(outputMsg); }