Ejemplo n.º 1
0
        public IActionResult UpdatePassenger(ChangeSeatsPassengersDTO passengerDTO)
        {
            if (passengerDTO == null)
            {
                return(BadRequest());
            }
            Passenger passenger1 = _passengerRepository.GetPassengerById(passengerDTO.UserId1);
            Passenger passenger2 = _passengerRepository.GetPassengerById(passengerDTO.UserId2);

            _passengerRepository.ChangeSeats(passenger1, passenger2);
            _passengerRepository.SaveChanges();
            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <PassengerDto> > GetPassengerById(int id, bool timeTable)
        {
            try

            {
                var result = await _passengerRepository.GetPassengerById(id, timeTable);

                var mappedResult = _mapper.Map <PassengerDto>(result);
                if (result == null)

                {
                    return(NotFound($"There is no passenger with ID:{id}"));
                }

                return(Ok(HateoasMainLinksPassenger(mappedResult)));
            }
            catch (Exception e)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $" Database failed {e.Message}"));
            }
        }