Example #1
0
        public async Task <Unit> Handle(RejectedPassengerBookingCommand request, CancellationToken cancellationToken)
        {
            var proposal = await _passengerBookingProposalRepository.GetOrFailAsync(request.ProposalId);

            var dailyRoute = await _dailyRouteRepository.GetOrFailAsync(proposal.DailyRouteId);

            dailyRoute.RejectedPassengerBookingProposal(request.RejectedReason, request.ProposalId);
            await _dailyRouteRepository.UpdateAsync(dailyRoute);

            return(Unit.Value);;
        }
        public async Task CreateAsync(Guid id, Guid proposalId)
        {
            var proposal = await _passengerBookingProposalRepository.GetOrFailAsync(proposalId);

            var dailyRoute = await _dailyRouteRepository.GetOrFailAsync(proposal.DailyRouteId);

            var driver = await _driverRepository.GetOrFailAsync(dailyRoute.DriverId);

            var user = await _userRepository.GetOrFailAsync(proposal.UserProposalId);

            var passengerBooking = new PassengerBooking(proposalId, id, driver.PhoneNumber, true,
                                                        user.Username, dailyRoute.Route.StartNode.Address,
                                                        dailyRoute.Route.EndNode.Address, dailyRoute.StartDate);

            await _passengerBookingRepository.CreateAsync(passengerBooking);
        }