public async Task CreateTrip(string basicUserId, NewTripDto newTrip)
        {
            var trip = mapper.Map <Trip>(newTrip);

            trip.BasicUserId = basicUserId;
            await tripsService.CreateTrip(trip);
        }
예제 #2
0
        public IHttpActionResult CreateNewTrips(NewTripDto newTrip)
        {
            var driver = _context.Drivers.Single(d => d.Id == newTrip.DriverId);


            var car = _context.Cars.Single(c => c.Id == newTrip.CarId);


            var packages = _context.Packages.Where(p => newTrip.PackageIds.Contains(p.Id)).ToList();



            foreach (var package in packages)
            {
                var trip = new Trip
                {
                    Driver           = driver,
                    Car              = car,
                    Package          = package,
                    DateLeftTheStore = DateTime.Now
                };


                _context.Trips.Add(trip);
            }

            _context.SaveChanges();

            return(Ok());
        }
예제 #3
0
        public async Task <ActionResult> CreateTrip([FromBody] NewTripDto newTripDto)
        {
            var applicationUserId = User.Claims.First(x => x.Type == "ApplicationUserId").Value;

            await this.tripsBusinessService.CreateTrip(applicationUserId, newTripDto);

            return(Ok());
        }