Пример #1
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);
        }