public void AddTest() { // dane wejściowe var driver = new Driver { FirstName = "Jan", LastName = "Nowak", Phone = "555-343-229", NumberId = "ALB443224" }; // operacja driversService.Add(driver); var drivers = driversService.Get(); var existsDriver = drivers .Where(d => d.FirstName == driver.FirstName) .Where(d => d.LastName == driver.LastName) .Where(d => d.Phone == driver.Phone) .Where(d => d.NumberId == driver.NumberId) .Any(); // sprawdzenie Assert.IsTrue(existsDriver, "Nie istnieje kierowca"); Assert.IsTrue(drivers.All(d => d.DriverId > 0), "DriverId jest równy 0"); }
public async Task <IHttpActionResult> Add([FromBody] DriverDTO model) { if (ModelState.IsValid) { var result = await _driversService.Add(model); return(result.IsSuccess ? StatusCode(HttpStatusCode.NoContent) : (IHttpActionResult)BadRequest(result.Error)); } else { return(BadRequest(ModelState)); } }
public async Task <DriverDto> Create(DriverDto entity) => await _driversSerice.Add(entity);