コード例 #1
0
        public ActionResult AddCircuitToTrip(int tripId, int templateId = 0)
        {
            BlViewTrip trip     = null;
            var        _blError = TripManager.GetTripById(tripId, out trip);

            if (_blError.ErrorCode != 0)
            {
                throw new ApplicationException(_blError.ErrorMessage);
            }

            var model = new TripViewModel();

            model.ActiveTrip = trip;

            BlTripTemplate template = null;

            _blError = TripManager.GetTripTemplatesById(templateId, out template);
            if (_blError.ErrorCode != 0)
            {
                throw new ApplicationException(_blError.ErrorMessage);
            }

            model.CreateTripTemplate = template;

            return(View(model));
        }
コード例 #2
0
        public ActionResult DeleteTrip(int tripId)
        {
            BlViewTrip trip     = null;
            var        _blError = TripManager.GetTripById(tripId, out trip);

            // error handling
            if (_blError.ErrorCode != 0)
            {
                throw new ApplicationException(_blError.ErrorMessage);
            }

            if (trip == null || trip.DlTripView == null)
            {
                throw new ApplicationException(String.Format("Invalid trip id requested: {0}", tripId));
            }

            if (trip.DlTripView.AspNetUserId != User.Identity.GetUserId())
            {
                throw new ApplicationException(String.Format("Unauthorized trip id requested: {0} by {1}", tripId, User.Identity.GetUserId()));
            }

            // looks like all ok
            var _model = new EditTripViewModel()
            {
                ActiveTrip = trip, RelatedTemplates = null
            };

            return(View(_model));
        }
コード例 #3
0
        public ActionResult EditTrip(int tripId)
        {
            BlViewTrip trip     = null;
            var        _blError = TripManager.GetTripById(tripId, out trip);

            // error handling
            if (_blError.ErrorCode != 0)
            {
                throw new ApplicationException(_blError.ErrorMessage);
            }

            if (trip == null || trip.DlTripView == null)
            {
                throw new ApplicationException(String.Format("Invalid trip id requested: {0}", tripId));
            }

            if (trip.DlTripView.AspNetUserId != User.Identity.GetUserId())
            {
                throw new ApplicationException(String.Format("Unauthorized trip id requested: {0} by {1}", tripId, User.Identity.GetUserId()));
            }

            // looks like all ok
            List <BlTripTemplate> _allTemplates     = null;
            List <BlTripTemplate> _relatedTemplates = new List <BlTripTemplate>();

            _blError = TripManager.SearchTripTemplatesByAlias(trip.DlTripView.TemplateSearchAlias, out _allTemplates);

            if (_allTemplates != null)
            {
                foreach (var template in _allTemplates)
                {
                    if (!trip.DlTripView.Templates.Contains(template.DlTemplate.Id.ToString()))
                    {
                        _relatedTemplates.Add(template);
                    }
                }
            }

            var startLocationOptions      = trip.DlTripView.StartLocation.Split('/').ToList();
            var _tripStartLocationOptions = new List <SelectListItem>();

            foreach (var startLocation in startLocationOptions)
            {
                _tripStartLocationOptions.Add(new SelectListItem()
                {
                    Text = startLocation, Value = startLocation
                });
            }

            var _model = new EditTripViewModel()
            {
                ActiveTrip = trip, RelatedTemplates = _relatedTemplates, TripStartLocationOptions = _tripStartLocationOptions
            };

            return(View("EditTrip", _model));
        }
コード例 #4
0
        public ActionResult ViewTrip(int tripId)
        {
            // get the trip details
            BlViewTrip trip     = null;
            var        _blError = TripManager.GetTripById(tripId, out trip);

            // error handling
            if (_blError.ErrorCode != 0)
            {
                throw new ApplicationException(_blError.ErrorMessage);
            }

            if (trip == null || trip.DlTripView == null)
            {
                throw new ApplicationException(String.Format("Invalid trip id requested: {0}", tripId));
            }

            if (trip.DlTripView.AspNetUserId != User.Identity.GetUserId())
            {
                throw new ApplicationException(String.Format("Unauthorized trip id requested: {0} by {1}", tripId, User.Identity.GetUserId()));
            }

            // all seems ok if you reach here
            List <BlTripTemplate> _allTemplates     = null;
            List <BlTripTemplate> _relatedTemplates = new List <BlTripTemplate>();

            _blError = TripManager.SearchRelatedTripTemplates(trip.DlTripView.Id, out _allTemplates);

            if (_allTemplates != null)
            {
                foreach (var template in _allTemplates)
                {
                    if (!trip.DlTripView.Templates.Contains(template.DlTemplate.Id.ToString()))
                    {
                        _relatedTemplates.Add(template);
                    }
                }
            }
            var _model = new TripViewModel()
            {
                ActiveTrip = trip, RelatedTemplates = _relatedTemplates
            };

            return(View("Trip", _model));
        }
コード例 #5
0
        public ActionResult RemoveDestinationFromTrip(int tripStepId, int tripId)
        {
            var        _model  = new RemoveDestinationFromTripViewModel();
            BlViewTrip tripObj = null;
            var        blError = TripManager.GetTripstepDetailsById(tripStepId, out tripObj);

            if (blError.ErrorCode != 0)
            {
                throw new ApplicationException(blError.ErrorMessage);
            }

            _model.DlTripStep               = tripObj.DlTripStepsView[0];
            _model.DlTrip                   = tripObj.DlTripView;
            _model.DlBookingsView           = tripObj.DlBookingsView;
            _model.DlTransportsBookingsView = tripObj.DlTransportsBookingsView;

            return(View(_model));
        }
コード例 #6
0
        public ActionResult AddTripBookingAccommodation(int tripStepId, int tripId)
        {
            BlViewTrip tripObj = null;
            var        blError = TripManager.GetTripById(tripId, out tripObj);

            if (blError.ErrorCode > 0)
            {
                throw new ApplicationException(blError.ErrorMessage);
            }

            var tripStepObj = tripObj.DlTripStepsView.FirstOrDefault(p => p.Id == tripStepId);

            if (tripStepObj == null)
            {
                throw new ApplicationException(string.Format("Invalid parameter - [TripStepId:{0}]", tripStepId));
            }

            var model = new AccommodationBookingViewModel()
            {
                TripName            = tripObj.DlTripView.Name,
                TripDescription     = tripObj.DlTripView.Description,
                TripStepName        = String.Format("{0} : {1}", tripStepObj.Destination, tripStepObj.ShortDescription),
                TripStepDescription = tripStepObj.LongDescription,
                TripStepStartDate   = tripStepObj.StartDate,
                TripStepEndDate     = tripStepObj.EndDate,
                TripStepId          = tripStepId,
                TripId     = tripId,
                Adults     = tripObj.DlTripView.PaxAdults,
                Kids       = tripObj.DlTripView.PaxMinors,
                TownOrCity = tripStepObj.Destination,
            };

            if (tripStepObj.StartDate.HasValue)
            {
                model.CheckinDate = tripStepObj.StartDate.Value;
            }

            if (tripStepObj.EndDate.HasValue)
            {
                model.CheckoutDate = tripStepObj.EndDate.Value;
            }

            return(View("AccommodationBooking", model));
        }
コード例 #7
0
ファイル: IdentityConfig.cs プロジェクト: yubanaswa/Travelogy
        /// <summary>
        ///
        /// </summary>
        /// <param name="aspNetUserId"></param>
        /// <returns></returns>
        public static BlViewTrip GetImmidiateTrip(string aspNetUserId)
        {
            try
            {
                BlViewTrip _trip = null;

                if (HttpContext.Current.Session["ImmediateTrip"] != null)
                {
                    _trip = HttpContext.Current.Session["ImmediateTrip"] as BlViewTrip;
                }
                else
                {
                    _trip = TripManager.GetImmediateTripForUser(aspNetUserId);
                    HttpContext.Current.Session.Add("ImmediateTrip", _trip);
                }

                return(_trip);
            }
            catch (Exception)
            {
                return(null);
            }
        }
コード例 #8
0
        public ActionResult AddFlightBooking(int tripId, int tripStepId = 0)
        {
            BlViewTrip tripObj = null;
            var        blError = TripManager.GetTripById(tripId, out tripObj);

            if (blError.ErrorCode > 0)
            {
                throw new ApplicationException(blError.ErrorMessage);
            }

            View_TripStep tripStepObj = null;

            if (tripStepId > 0)
            {
                tripStepObj = tripObj.DlTripStepsView.FirstOrDefault(p => p.Id == tripStepId);
                if (tripStepObj == null)
                {
                    throw new ApplicationException(string.Format("Invalid parameter - [TripStepId:{0}]", tripStepId));
                }
            }

            var model = new FlightBookingViewModel()
            {
                TripBookingTransportId = 0,
                TripId          = tripId,
                TripStepId      = tripStepId,
                TripName        = tripObj.DlTripView.Name,
                TripDescription = tripObj.DlTripView.Description,
                Adults          = tripObj.DlTripView.PaxAdults,
                Kids            = tripObj.DlTripView.PaxMinors,
                TripStartDate   = (tripStepObj != null && tripStepObj.StartDate.HasValue) ? tripStepObj.StartDate : tripObj.DlTripView.StartDate,
                FlightDate      = (tripStepObj != null && tripStepObj.StartDate.HasValue) ? tripStepObj.StartDate.Value : tripObj.DlTripView.StartDate.Value,
            };

            return(View("FlightBooking", model));
        }