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)); }
/// <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); } }
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)); }