예제 #1
0
        public ActionResult CreateTripForCountry(string country)
        {
            BlTripTemplate _template = null;
            var            _blerror  = TripManager.GetDefaultTemplateForCountry(country, out _template);

            if (_blerror.ErrorCode > 0 || _template == null || _template.DlTemplate == null)
            {
                throw new ApplicationException("No GetDefaultTemplateForCountry for: " + country);
            }

            // assign the template to the view model
            var _model = new TripViewModel();

            _model.CreateTripTemplate = _template;
            _model.CreateTripViewModel
                = new CreateTripViewModel()
                {
                DestinationId = _template.DlTemplate.DestinationId,
                TemplateId    = _template.DlTemplate.Id,
                StartDate     = DateTime.Now
                };

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

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

            _model.CreateTripStartLocationOptions = _tripStartLocationOptions;

            return(View("Trip", _model));
        }