protected override Task Handle(UpdateTripCommand request, CancellationToken cancellationToken)
        {
            if (request.Trip == null)
            {
                throw new ArgumentNullException();
            }

            var trip = _tripsRepository.Exists(request.Trip.Id);

            if (!trip)
            {
                throw new EntityNotFoundException($"Not found trip with id: {request.Trip.Id}");
            }

            foreach (var destination in request.Trip.TripDestinations)
            {
                if (destination.TripDestinationTypeId == (int)TripDestinationType.Mountain && destination.MountainId != null)
                {
                    if (!_mountainsRepository.Exists(destination.MountainId.Value))
                    {
                        throw new EntityNotFoundException($"Not found mountain with id: {destination.MountainId.Value}");
                    }
                }
                else
                {
                    throw new ValidationException();
                }
            }
            _tripDestinationRepository.Delete(request.Trip.Id);
            _tripsRepository.Update(request.Trip);
            return(Task.CompletedTask);
        }
 public async Task <ActionResult <FETrip> > Put([FromBody]  FETrip newTrip, [FromQuery] UpdateTripRequest updateTripRequest) //same result with same request
 {
     try
     {
         return(await tripsRepository.Update(newTrip, updateTripRequest));
     }
     catch (InvalidOperationException e)
     {
         return(BadRequest(e));
     }
     catch (Exception e)
     {
         return(StatusCode(500, e));
     }
 }