예제 #1
0
        public async Task <BatchTripReservationViewModel> Post([FromBody] BatchTripReservationViewModel batchTripReservation)
        {
            var batchTripReservationModel = _reservationMapper.ToModel(batchTripReservation);

            _context.BatchTripReservations.Add(batchTripReservationModel);
            await _context.SaveChangesAsync();

            var batchTripReservationViewModel = _reservationMapper.ToViewModel(batchTripReservationModel);

            return(batchTripReservationViewModel);
        }
예제 #2
0
        public TripScheduleViewModel ToViewModel(TripSchedule model, bool includeReservation = false)
        {
            var tripScheduleViewModel = new TripScheduleViewModel
            {
                Id           = model.Id,
                UserId       = model.UserId,
                ScheduleDate = model.ScheduleDateTime.ToString("MM/dd/yyyy"),
                ScheduleTime = model.ScheduleDateTime.ToString("hh:mm tt"),
                LandMarks    = model.TripLandMarks.Select(tl => ToViewModel(tl)).ToList()
            };

            if (includeReservation)
            {
                tripScheduleViewModel.TripReservations
                    = model.TripReservations.Select(tr => _tripReservationMapper.ToViewModel(tr, includeReservation)).ToList();
            }

            return(tripScheduleViewModel);
        }