Ejemplo n.º 1
0
        public async Task <PropertyResponse> Handle(UpdatePropertyCommand request, CancellationToken cancellationToken)
        {
            var property = await _propertiesService.GetPropertyByIdAsync(request.Id);

            _mapper.Map(request, property);

            await _propertiesService.UpdatePropertyAsync(property);

            return(_mapper.Map <PropertyResponse>(property));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        public async Task <PropertyResponse> Handle(GetPropertyByIdQuery request, CancellationToken cancellationToken)
        {
            var property = await _propertiesService.GetPropertyByIdAsync(request.Id);

            return(_mapper.Map <PropertyResponse>(property));
        }