コード例 #1
0
        public ActionResult SaveTravellerProfile(TravellerProfileViewModel profileView)
        {
            Traveller _travellerProfile = null;
            // get the traveller profile, if exists
            var _blError = TravellerProfileManager.GetTravellerProfile(User.Identity.GetUserId(), out _travellerProfile);

            // if not found, create a new profile
            if (_blError.ErrorCode != 0 || _travellerProfile == null)
            {
                _travellerProfile = new Traveller();
            }

            _travellerProfile.FirstName       = profileView.FirstName;
            _travellerProfile.LastName        = profileView.LastName;
            _travellerProfile.Telephone       = profileView.Telephone;
            _travellerProfile.Mobile          = profileView.Mobile;
            _travellerProfile.AddressLine1    = profileView.AddressLine1;
            _travellerProfile.AddressLine2    = profileView.AddressLine2;
            _travellerProfile.City            = profileView.City;
            _travellerProfile.Country         = profileView.Country;
            _travellerProfile.PostCode        = profileView.PostCode;
            _travellerProfile.TravelGroupSize = profileView.TravelGroupSize;
            _travellerProfile.TravelStyle     = profileView.TravelStyle;
            _travellerProfile.TravelInterests = _GetInterests(profileView.TravellerInterests);

            _travellerProfile.AspnetUserid = User.Identity.GetUserId();

            _blError = TravellerProfileManager.UpdateUserTravellerProfile(_travellerProfile);

            return(RedirectToAction("TravellerProfile"));
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public ActionResult TravellerProfile()
        {
            Traveller _travellerProfile = null;
            // get the traveller profile, if exists
            var _blError = TravellerProfileManager.GetTravellerProfile(User.Identity.GetUserId(), out _travellerProfile);

            // if not found, create a new profile
            if (_blError.ErrorCode != 0 || _travellerProfile == null)
            {
                _travellerProfile = new Traveller();
            }

            var _model = new TravellerProfileViewModel()
            {
                FirstName       = _travellerProfile.FirstName,
                LastName        = _travellerProfile.LastName,
                Telephone       = _travellerProfile.Telephone,
                Mobile          = _travellerProfile.Mobile,
                AddressLine1    = _travellerProfile.AddressLine1,
                AddressLine2    = _travellerProfile.AddressLine2,
                City            = _travellerProfile.City,
                Country         = _travellerProfile.Country,
                TravelGroupSize = _travellerProfile.TravelGroupSize,
                PostCode        = _travellerProfile.PostCode,
                TravelStyle     = _travellerProfile.TravelStyle,
                ListOfCountries = _GetCountries()
            };

            if (string.IsNullOrEmpty(_travellerProfile.TravelInterests))
            {
                _travellerProfile.TravelInterests = string.Empty;
            }

            // get the tags and create the check boxes for the traveller profile
            List <Tag> tags    = null;
            var        blError = TagManager.GetAllTags(out tags);

            _model.TravellerInterests = new List <TravellerInterestCheckModel>();

            foreach (var tag in tags)
            {
                _model.TravellerInterests.Add(new TravellerInterestCheckModel()
                {
                    Checked = _travellerProfile.TravelInterests.IndexOf(tag.TagDisplay) > 0, Id = tag.Id, Name = tag.TagDisplay
                });
            }

            return(View(_model));
        }