public void GetAllIncludesAllRelationsOfDriver() { var person = new Person(); var driver = new Driver { Person = person }; _sut.Add(driver); var drivers = _sut.GetAll(); Assert.That(drivers, Is.Not.Null); var driverFromDatabase = drivers.FirstOrDefault(b => b.Id == driver.Id); Assert.That(driverFromDatabase.Person, Is.EqualTo(person)); }
public string CreateDriver(string driverName) { if (driverRepository.GetByName(driverName) != null) { throw new ArgumentException(string.Format(ExceptionMessages.DriversExists, driverName)); } driverRepository.Add(new Driver(driverName)); return(string.Format(OutputMessages.DriverCreated, driverName)); }
public string CreateDriver(string driverName) { if (driverRepository.GetAll().Any(x => x.Name == driverName)) { throw new ArgumentException(string.Format(ExceptionMessages.DriversExists, driverName)); } driverRepository.Add(new Driver(driverName)); return($"Driver {driverName} is created."); }
public string CreateDriver(string driverName) { if (drivers.GetAll().Any(x => x.Name == driverName)) { throw new ArgumentException($"Driver {driverName} is already created."); } drivers.Add(new Driver(driverName)); return($"Driver {driverName} is created."); }
public string CreateDriver(string driverName) { IDriver driver = new Driver(driverName); if (DriverRepository.Colection.Any(el => el.Name == driverName)) { throw new ArgumentException(string.Format(ExceptionMessages.DriversExists, driverName)); } DriverRepository.Add(driver); return(string.Format(OutputMessages.DriverCreated, driverName)); }
static async Task Main(string[] args) { DriverRepository repository = new DriverRepository(); await repository.Add(new IBA_Test_DAL.Models.DriverDAL("6141 HE-5", DateTime.Now, 78.9f)); await repository.Add(new IBA_Test_DAL.Models.DriverDAL("9857 KM-7", DateTime.Now, 98.3f)); await repository.Add(new IBA_Test_DAL.Models.DriverDAL("9857 KM-7", DateTime.Now.AddDays(12), 98.3f)); InsertWithSQL(new Model("6141 HE-5", DateTime.Now, 78.9f)); InsertWithSQL(new Model("9857 KM-7", DateTime.Now, 98.3f)); InsertWithSQL(new Model("9857 KM-7", DateTime.Now.AddDays(12), 98.3f)); InsertWithSQL(new Model("9857 KM-7", DateTime.Now.AddDays(-10), 98.3f)); InsertWithSQL(new Model("1245 KB-3", DateTime.Now, 85.0f)); GetWithSQL(); var model = GetInfoFromStorage("1245 KB-3"); Console.WriteLine(model.ToString()); Console.ReadKey(); }
public string CreateDriver(string driverName) { if (driverRepository.Models.Any(d => d.Name == driverName)) { throw new ArgumentException(string.Format(ExceptionMessages.DriversExists, driverName)); } IDriver driver = new Driver(driverName); driverRepository.Add(driver); return($"{string.Format(OutputMessages.DriverCreated, driverName)}"); }
public string CreateDriver(string driverName) { IDriver driver = driverRepository.GetByName(driverName); if (driver != null) { throw new ArgumentException($"Driver {driverName} is already created."); } driverRepository.Add(new Driver(driverName)); return($"Driver {driverName} is created."); }
public string CreateDriver(string driverName) { var driverExists = this.driverRepository.GetByName(driverName); if (driverExists != null) { throw new ArgumentException($"Driver {driverName} is already created."); } var driver = new Driver(driverName); driverRepository.Add(driver); return($"Driver {driverName} is created."); }
public string CreateDriver(string driverName) { IDriver driverFromRepository = driverRepository.GetAll() .FirstOrDefault(x => x.Name == driverName); if (driverFromRepository != null) { throw new ArgumentException(String.Format(ExceptionMessages.DriversExists, driverName)); } IDriver driver = new Driver(driverName); driverRepository.Add(driver); return(String.Format(OutputMessages.DriverCreated, driverName)); }
public string CreateDriver(string driverName) { var driver = driveRep.GetByName(driverName); Driver newDriver = new Driver(driverName); if (driver != null) { throw new ArgumentException($"Driver {driverName} is already created."); } else { driveRep.Add(newDriver); return($"Driver {driverName} is created."); } }
public string CreateDriver(string driverName) { if (drivers.GetAll().Any(x => x.Name == driverName)) { string msg = string.Format(ExceptionMessages.DriversExists, driverName); throw new ArgumentException(msg); } IDriver driver = new Driver(driverName); drivers.Add(driver); string outputMsg = string.Format(OutputMessages.DriverCreated, driverName); return(outputMsg); }
public HttpResponseMessage Post([FromBody] DriverBO driverBO) { Data.driver _driver = new Data.driver(); //_driver.driverkey = driverBO.DriverKey; _driver.firstname = driverBO.FirstName; _driver.lastname = driverBO.LastName; _driver.driverid = driverBO.DriverId; _driver.drivinglicenseno = driverBO.DriversLicenseNo; _driver.drivinglicenseexpirydate = driverBO.LicenseExpiryDate; _driver.vendkey = driverBO.VendorKey; _driver.createdate = DateTime.Now; _driver.status = 1; _driver.statusdate = DateTime.Now; if (driverBO.Address != null) { var custaddress = new Data.address() { address1 = driverBO.Address.Address1, address2 = driverBO.Address.Address2, city = driverBO.Address.City, state = driverBO.Address.State, country = driverBO.Address.Country, zipcode = driverBO.Address.Zip, email = driverBO.Address.Email, fax = driverBO.Address.Fax, addrname = _driver.driverid }; var addrkey = new AddressRepository().Add(custaddress); _driver.addrkey = addrkey; } Guid custId = repo.Add(_driver); if (custId != null && custId != Guid.Empty) { return(Request.CreateResponse(HttpStatusCode.OK, custId, Configuration.Formatters.JsonFormatter)); } else { return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } }