public async Task <AddResult> AddAsync(Airport airport) { AirportEntity airportDal = _mapper.Map <AirportEntity>(airport); bool duplicate = await _airportRepository.CheckDuplicateAsync(airportDal); if (duplicate) { return(new AddResult(ResultTypes.Duplicate, null)); } int addedAirportId = await _airportRepository.AddAsync(airportDal); return(new AddResult(ResultTypes.Ok, addedAirportId)); }
public async Task <ResultTypes> UpdateAsync(Airport airport) { AirportEntity oldAirportDal = await _airportRepository.GetByIdAsync(airport.Id); if (oldAirportDal == null) { return(ResultTypes.NotFound); } AirportEntity airportDal = _mapper.Map <AirportEntity>(airport); bool duplicate = await _airportRepository.CheckDuplicateAsync(airportDal); if (duplicate) { return(ResultTypes.Duplicate); } await _airportRepository.UpdateAsync(airportDal); return(ResultTypes.Ok); }
public async Task <Airport> GetByIdAsync(int id) { AirportEntity foundAirport = await _airportRepository.GetByIdAsync(id); return(_mapper.Map <Airport>(foundAirport)); }