Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 3
0
        public void ShouldGetTripByIdReturnRightTrip()
        {
            var sampleTrip = Trips.First();
            var trip       = TripManager.GetTripById(sampleTrip.Key);

            Assert.That(trip, Is.EqualTo(sampleTrip.Value));
            var unused = Uow.DidNotReceive().CommitAsync();
        }
Esempio n. 4
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));
        }
Esempio n. 5
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));
        }
Esempio n. 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));
        }
Esempio n. 7
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));
        }