Ejemplo n.º 1
0
        public async Task <Unit> Handle(RemoveDailyRouteCommand request, CancellationToken cancellationToken)
        {
            var route = await _routeRepository.GetOrFailAsync(request.RouteId);

            await _routeRepository.RemoveAsync(request.RouteId);

            return(Unit.Value);;
        }
Ejemplo n.º 2
0
        public async Task <Unit> Handle(CreatePassengerBookingProposalCommand request, CancellationToken cancellationToken)
        {
            var dailyRoute = await _dailyRouteRepository.GetOrFailAsync(request.DailyRouteId);

            dailyRoute.AddPassengerBookingProposal(DateTime.Now, Guid.NewGuid(), request.UserId, request.SeatsQuantity);
            await _dailyRouteRepository.UpdateAsync(dailyRoute);

            return(Unit.Value);
        }
Ejemplo n.º 3
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);
        }