Ejemplo n.º 1
0
        public async Task <BookingResponse> Handle(CreateBookingCommand request, CancellationToken cancellationToken)
        {
            var booking = _mapper.Map <Booking>(request);

            var property = await _propertiesService.GetPropertyByIdAsync(booking.PropertyId);

            booking.UserId        = _userResolverService.GetUserId();
            booking.PricePerNight = property.PricePerNight;
            booking.TotalPrice    = (booking.CheckOutDate - booking.CheckInDate).Days * booking.PricePerNight;

            await _bookingsService.CreateBookingAsync(booking);

            return(_mapper.Map <BookingResponse>(booking));
        }