public async Task AddingDuplicateAirportReturnsDuplicateResult() { // Arrange Airport airport = new Airport() { Name = "Minsk airport", CityId = 1 }; // Act AddResult addResult = await _airportService.AddAsync(airport); //Assert Assert.AreEqual(ResultTypes.Duplicate, addResult.ResultType); }
public async Task <ActionResult> AddAsync([FromBody] Airport airport) { BlAirport airportBl = _mapper.Map <BlAirport>(airport); AddResult addAddResult = await _airportService.AddAsync(airportBl); if (addAddResult.ResultType == ResultTypes.Duplicate) { return(BadRequest()); } return(Ok(new { Id = addAddResult.ItemId })); }
public async Task <ActionResult <bool> > Add(string docId, Airports airports) { try { return(Ok(new Notification { Success = true, Data = await _airportService.AddAsync(docId, airports) })); } catch (Exception ex) { return(BadRequest(new Notification { Success = false, Errors = ex.Message })); } }