コード例 #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 void CreateNewUser(User user)
        {
            string Email = user.Email;

            string[] Username = Email.Split("@");
            user.Username = Username[0];
            _repository.Post(user);
        }
コード例 #3
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);
        }
コード例 #4
0
 public void CreateCar(Car car, long userId)
 {
     car.CarOwnerId = userId;
     _repository.Post(car);
 }