Exemplo 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));
        }
Exemplo n.º 2
0
        public ActionResult CreateTripFromTemplate(int templateId)
        {
            // get the trip template
            BlTripTemplate _template = null;
            var            _blerror  = TripManager.GetTripTemplatesById(templateId, out _template);

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

            _model.CreateTripTemplate = _template;

            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;

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

            return(View("Trip", _model));
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
0
        public ActionResult ViewTripTemplate(int TemplateId)
        {
            BlTripTemplate _template = null;
            var            _blError  = TripManager.GetTripTemplatesById(TemplateId, out _template);

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

            var _model = new ViewTripTemplateViewModel()
            {
                TripTemplate = _template
            };

            var _trip = TripManager.GetImmediateTripForUser(User.Identity.GetUserId());

            if (_trip != null)
            {
                _model.TripId = _trip.DlTripView.Id;
            }

            return(View(_model));
        }