Beispiel #1
0
        public void CreateRideBooking(RideBooking booking)
        {
            Booking rideBooking = _mapper.Map <RideBooking, Booking>(booking);

            rideBooking.Id     = GenerateId();
            rideBooking.Status = BookingStatus.Requested;

            _repository.Post(rideBooking);

            User user = _userRepository.Get(rideBooking.BookingUserId);

            if (user != null)
            {
                user.LastBookingId = rideBooking.Id;
                _userRepository.Put(user);
            }

            OfferRide RideOffer = _rideOffersRepository.Get(booking.RideOfferId);

            if (RideOffer != null)
            {
                RideOffer.AvailableSeats = RideOffer.AvailableSeats - booking.Seats;
                _rideOffersRepository.Put(RideOffer);
            }
        }
        public ProfileDetails GetUserDetails(long id)
        {
            User           user           = _repository.Get(id);
            ProfileDetails profileDetails = _mapper.Map <User, ProfileDetails>(user);

            return(profileDetails);
        }
Beispiel #3
0
        public RideDetails GetBooking(long bookingId)
        {
            Booking UserBooking = _repository.Get(bookingId);

            if (UserBooking != null)
            {
                RideDetails BookedRide = _mapper.Map <Booking, RideDetails>(UserBooking);
                BookedRide.Name            = _userRepository.Get(_rideOffersRepository.Get(UserBooking.RideOfferId).HostId).Name;
                BookedRide.StartPoint      = UserBooking.StartPoint.Split(",")[0];
                BookedRide.Destination     = UserBooking.Destination.Split(",")[0];
                BookedRide.RideBookingDate = UserBooking.RideBookingDate.ToString("dd/MM/yyyy");
                return(BookedRide);
            }
            else
            {
                return(null);
            }
        }
Beispiel #4
0
        public LastActionKeys GetLastActionIds(long userId)
        {
            User           User           = _repository.Get(userId);
            LastActionKeys LastActionKeys = new LastActionKeys()
            {
                LastBookingId     = User.LastBookingId,
                LastRideOfferedId = User.LastOfferRideId
            };

            return(LastActionKeys);
        }
Beispiel #5
0
        public void CreateRideOffer(long userId, RideOffer rideOffer)
        {
            OfferRide NewRideOffer = _mapper.Map <RideOffer, OfferRide>(rideOffer);

            NewRideOffer.RideOfferId = GenerateId();
            NewRideOffer.HostId      = userId;

            _repository.Post(NewRideOffer);

            foreach (string area in rideOffer.Route)
            {
                Place NewPlace = new Place
                {
                    AreaName    = area,
                    RideOfferId = NewRideOffer.RideOfferId
                };
                NewRideOffer.Route.Add(NewPlace);
            }
            _routeRepository.AddRange(NewRideOffer.Route);
            User user = _userRepository.Get(userId);

            user.LastOfferRideId = NewRideOffer.RideOfferId;
            _userRepository.Put(user);
        }
Beispiel #6
0
        public IActionResult Index()
        {
            var data = _databaseTableModel.Get(1);

            return(View());
        }