Exemple #1
0
        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);
        }
Exemple #2
0
        public async Task <bool> CheckFlightSeatTypeCostDuplicateAsync(FlightSeatTypeCostEntity seatTypeCost)
        {
            FlightSeatTypeCostEntity duplicate = _flightSeatTypeCostData.FirstOrDefault(
                x => x.FlightId == seatTypeCost.FlightId && x.SeatTypeId == seatTypeCost.SeatTypeId
                );

            return(duplicate != null);
        }
Exemple #3
0
        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));
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        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);
        }
Exemple #7
0
 public async Task UpdateFlightSeatTypeCostAsync(FlightSeatTypeCostEntity seatTypeCost)
 {
     // implementation
 }