Ejemplo n.º 1
0
        public ActionResult ListAllTripTemplates(string templateAlias)
        {
            var _availableTemplates = new List <BlTripTemplate>();
            var _allTemplates       = new List <BlTripTemplate>();
            var _blError            = TripManager.SearchTripTemplatesByAlias(templateAlias, out _availableTemplates);
            var _trip = TripManager.GetImmediateTripForUser(User.Identity.GetUserId());

            if (_availableTemplates != null)
            {
                foreach (var template in _availableTemplates)
                {
                    // if there is already a trip that includes this template - then
                    if (_trip != null && _trip.DlTripView != null && !String.IsNullOrEmpty(_trip.DlTripView.Templates) &&
                        _trip.DlTripView.Templates.Contains(template.DlTemplate.Id.ToString()))
                    {
                        // do nothing
                    }

                    else // add it to the available list
                    {
                        _allTemplates.Add(template);
                    }
                }
            }

            var _model = new TripViewModel()
            {
                AliasName    = templateAlias,
                AllTemplates = _allTemplates
            };

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

            if (_availableTemplates.Count > 0)
            {
                _model.Country = _availableTemplates[0].Country;
            }

            return(View("TripTemplates", _model));
        }
Ejemplo n.º 2
0
        /// <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);
            }
        }
Ejemplo n.º 3
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));
        }