public async Task <ResultTypes> AddFlightSeatTypeCostAsync(FlightSeatTypeCost seatTypeCost) { FlightSeatTypeCostEntity seatTypeCostDal = _mapper.Map <FlightSeatTypeCostEntity>(seatTypeCost); FlightEntity flight = await _flightRepository.GetByIdAsync(seatTypeCostDal.FlightId); if (flight == null) { return(ResultTypes.NotFound); } AirplaneSeatTypeEntity seatType = await _airplaneRepository.GetSeatTypeById(seatTypeCostDal.SeatTypeId); if (seatType == null) { return(ResultTypes.NotFound); } bool duplicate = await _flightRepository.CheckFlightSeatTypeCostDuplicateAsync(seatTypeCostDal); if (duplicate) { return(ResultTypes.Duplicate); } await _flightRepository.AddFlightSeatTypeCostAsync(seatTypeCostDal); return(ResultTypes.Ok); }
public async Task <bool> CheckFlightSeatTypeCostDuplicateAsync(FlightSeatTypeCostEntity seatTypeCost) { FlightSeatTypeCostEntity duplicate = _flightSeatTypeCostData.FirstOrDefault( x => x.FlightId == seatTypeCost.FlightId && x.SeatTypeId == seatTypeCost.SeatTypeId ); return(duplicate != null); }
public async Task <bool> CheckFlightSeatTypeCostDuplicateAsync(FlightSeatTypeCostEntity seatTypeCost) { using SqlConnection db = new SqlConnection(_dalSettings.ConnectionString); return(await db.ExecuteScalarAsync <bool>( "CheckFlightSeatTypeCostDuplicate", new { FlightId = seatTypeCost.FlightId, SeatTypeId = seatTypeCost.SeatTypeId, }, commandType : CommandType.StoredProcedure)); }
public async Task UpdateFlightSeatTypeCostAsync(FlightSeatTypeCostEntity seatTypeCost) { using SqlConnection db = new SqlConnection(_dalSettings.ConnectionString); await db.ExecuteAsync( "UpdateFlightSeatTypeCost", new { FlightId = seatTypeCost.FlightId, SeatTypeId = seatTypeCost.SeatTypeId, Cost = seatTypeCost.Cost }, commandType : CommandType.StoredProcedure); }
public async Task AddFlightSeatTypeCostAsync(FlightSeatTypeCostEntity seatTypeCost) { using SqlConnection db = new SqlConnection(_dalSettings.ConnectionString); await db.QuerySingleOrDefaultAsync( "AddFlightSeatTypeCost", new { FlightId = seatTypeCost.FlightId, SeatTypeId = seatTypeCost.SeatTypeId, Cost = seatTypeCost.Cost }, commandType : CommandType.StoredProcedure); }
public async Task <ResultTypes> UpdateFlightSeatTypeCostAsync(FlightSeatTypeCost newSeatTypeCost) { FlightSeatTypeCostEntity seatTypeCostDal = _mapper.Map <FlightSeatTypeCostEntity>(newSeatTypeCost); FlightEntity flight = await _flightRepository.GetByIdAsync(seatTypeCostDal.FlightId); if (flight == null) { return(ResultTypes.NotFound); } AirplaneSeatTypeEntity seatType = await _airplaneRepository.GetSeatTypeById(seatTypeCostDal.SeatTypeId); if (seatType == null) { return(ResultTypes.NotFound); } await _flightRepository.UpdateFlightSeatTypeCostAsync(seatTypeCostDal); return(ResultTypes.Ok); }
public async Task UpdateFlightSeatTypeCostAsync(FlightSeatTypeCostEntity seatTypeCost) { // implementation }