예제 #1
0
        private Section LoadSubSection(Section model, OwnerSectionCache ownerSectionCache)
        {
            //Evaluate if this section should be displayed
            if (SitecoreUtils.EvaluateRules(model.RestrictionRule, model.InnerItem))
            {
                model.HideSection = false;

                var context  = new SitecoreContext();
                var homePage = context.GetHomeItem <BasePage>();

                BlueGreenContext bgContext = new BlueGreenContext();
                string           ownerId   = bgContext.OwnerId;
                if (model.LazyLoadContent)
                {
                }
                else
                {
                    OwnerUtils.GetSectionTableData(ref model, ownerId, homePage.SiteSettings, ownerSectionCache);
                }
            }
            else
            {
                model.HideSection = true;
            }

            return(model);
        }
예제 #2
0
        public ActionResult DoSearch(SearchParameters tmpSearch)
        {
            DebugUtils.StartLogEvent("HomeController.DoSearch");


            if (string.IsNullOrEmpty(tmpSearch.ReservationType))
            {
                tmpSearch.ReservationType = "1";
            }
            if (tmpSearch.ReservationType == "2" && !string.IsNullOrEmpty(tmpSearch.DestinationBonusTime))
            {
                tmpSearch.Destination = tmpSearch.DestinationBonusTime;
            }

            if (tmpSearch.Destination != null && !tmpSearch.Destination.ToLower().Contains("all-"))
            {
                tmpSearch.CheckInDate  = DateTime.MinValue;
                tmpSearch.CheckOutDate = DateTime.MinValue;
            }
            SearchParametersManager searchParametersManager = new SearchParametersManager(false);

            searchParametersManager.parameter = tmpSearch;

            searchParametersManager.SaveParameters();

            DebugUtils.EndLogEvent("HomeController.DoSearch");
            if (tmpSearch.Destination == null)
            {
                return(null);
            }
            else
            {
                return(Redirect(SitecoreUtils.GetPageUrl(SitecoreItemReferences.SearchResultPage)));
            }
        }
예제 #3
0
        public ActionResult FacebookWidget()
        {
            var model = GetDataSourceItem <SocialWidget>();

            if (model != null & SitecoreUtils.EvaluateRules(model.RestrictionRule, model.InnerItem))
            {
                model.IsAllowed = true;
            }
            return(View(model));
        }
예제 #4
0
        public ActionResult PageAlerts()
        {
            DebugUtils.StartLogEvent("AlertController.PageAlerts");
            var model = GetLayoutItem <AllAlerts>();

            if (model.AllAlert != null && model.AllAlert.Count() > 0)
            {
                List <Alert> allAllerts = (List <Alert>)model.AllAlert;

                foreach (var alert in allAllerts.Reverse <Alert>())
                {
                    if (!SitecoreUtils.EvaluateRules(alert.AlertRules, ContextItem))
                    {
                        allAllerts.Remove(alert);
                    }
                    else
                    {
                        BlueGreenContext bgContext = new BlueGreenContext();
                        if (alert.AlertText.Contains("{TPNoLongerAvailableDate}"))
                        {
                            if (bgContext.OwnerExpiration != null)
                            {
                                string valueToUpdate = bgContext.OwnerExpiration.Value.AddYears(1).ToString("MM/dd/yyyy");
                                alert.AlertText = alert.AlertText.Replace("{TPNoLongerAvailableDate}", valueToUpdate);
                            }
                        }
                        if (alert.AlertText.Contains("{WaiverCount}"))
                        {
                            ResortService service     = new ResortService();
                            var           waiverCount = service.OwnerWaivers(FormatUtils.ConvertStringToInt(bgContext.OwnerId));
                            if (waiverCount != null && waiverCount.OwnerWaivers != null)
                            {
                                alert.AlertText = alert.AlertText.Replace("{WaiverCount}", waiverCount.OwnerWaivers.WaiversAvailable);
                            }
                            else
                            {
                                allAllerts.Remove(alert);
                            }
                        }
                        if (alert.AlertText.Contains("{PointsExpirationDate}"))
                        {
                            DateTime?pointsExpirationDate = bgContext?.GetPointsExpireDate();
                            if (pointsExpirationDate != null)
                            {
                                string valueToUpdate = pointsExpirationDate.Value.ToString("MM/dd/yyyy");
                                alert.AlertText = alert.AlertText.Replace("{PointsExpirationDate}", valueToUpdate);
                            }
                        }
                    }
                }
                model.AllAlert = allAllerts;
                DebugUtils.EndLogEvent("AlertController.PageAlerts");
            }
            return(View(model));
        }
예제 #5
0
        public ActionResult Featured()
        {
            DebugUtils.StartLogEvent("HomeController.Featured");
            var model = new FeaturedItemsCache();

            if (Session["AllFeaturedItems"] != null)
            {
                model = (FeaturedItemsCache)Session["AllFeaturedItems"];
            }
            else
            {
                var allFeatures            = GetLayoutItem <FeaturedItems>();
                FeaturedItemsCache tmpList = new FeaturedItemsCache();
                tmpList.AllFeaturedItems     = new List <FeaturedItemCache>();
                tmpList.PageTitle            = allFeatures.PageTitle;
                allFeatures.AllFeaturedItems = allFeatures.AllFeaturedItems.Where(x => ((x.StartDate == DateTime.MinValue || x.StartDate <= DateTime.Now) &&
                                                                                        (x.EndDate == DateTime.MinValue || x.EndDate >= DateTime.Now))).Select(featuredItem => featuredItem);

                foreach (FeaturedItem item in allFeatures.AllFeaturedItems)
                {
                    if (item.Active && item.AccessibleHomePage)
                    {
                        if (item.InnerItem.Fields[BaseComponent.RestrictionRuleId] != null)
                        {
                            String rule = item.InnerItem.Fields[BaseComponent.RestrictionRuleId].Value;
                            if (!string.IsNullOrEmpty(rule))
                            {
                                if (SitecoreUtils.EvaluateRules(rule, item.InnerItem))
                                {
                                    FeaturedItemCache newItem = new Models.FeaturedItemCache();
                                    newItem.PageTitle    = item.PageTitle;
                                    newItem.ImageSrc     = ImageUtils.BuildImageUrl(item.FeaturedImage, allFeatures.SiteSettings.RemoteImageUrl, "/images/white.png");
                                    newItem.ImageCaption = item.Caption;
                                    newItem.ImageHref    = item.RedirectLink == null ? item.Url : item.RedirectLink.Url;
                                    newItem.Category     = item.Category;

                                    tmpList.AllFeaturedItems.Add(newItem);
                                }
                            }
                        }
                    }
                }
                if (tmpList.AllFeaturedItems.Count > 0)
                {
                    tmpList.AllFeaturedItems = tmpList.AllFeaturedItems.OrderBy(o => o.Category).ToList();
                }
                model = tmpList;
                Session["AllFeaturedItems"] = tmpList;
            }
            DebugUtils.EndLogEvent("HomeController.Featured");

            return(View(model));
        }
예제 #6
0
        public ActionResult Wysiwyg()
        {
            var model = GetLayoutItem <Wysiwyg>();

            if (SitecoreUtils.EvaluateRules(model.RestrictionRule, model.InnerItem))
            {
                return(View(model));
            }
            else
            {
                return(new EmptyResult());
            }
        }
        public static SyncItem AttachMediaFile(this SyncItem syncItem, FileInfo fileInfo)
        {
            byte[] bytes     = FileUtils.ReadFile(fileInfo.FullName);
            var    blobValue = System.Convert.ToBase64String(bytes, Base64FormattingOptions.InsertLineBreaks);
            string extension = fileInfo.Extension.TrimStart('.');
            string mimeType  = MediaTypeResolver.Instance.ResolveMimeType(extension);

            syncItem.SetFieldValue(FileTemplateFields.Blob, blobValue);
            syncItem.SetFieldValue(FileTemplateFields.Size, bytes.Length.ToString());
            syncItem.SetFieldValue(FileTemplateFields.Extension, extension);
            syncItem.SetFieldValue(FileTemplateFields.MimeType, mimeType);
            syncItem.SetFieldValue(FileTemplateFields.Icon, SitecoreUtils.GenerateIconValue(syncItem.ID));
            return(syncItem);
        }
예제 #8
0
 public ActionResult ShowFlexResort()
 {
     DebugUtils.StartLogEvent("HomeController.ShowFlexResort");
     if (Session["OwnerHomeResort"] != null)
     {
         string resortId = Session["OwnerHomeResort"].ToString();
         var    resort   = ResortManager.FindResort(FormatUtils.ConvertStringToInt(resortId));
         if (resort != null)
         {
             Server.TransferRequest(SitecoreUtils.GetPageUrl(resort.InnerItem));
         }
         DebugUtils.EndLogEvent("HomeController.ShowFlexResort");
     }
     return(null);
 }
예제 #9
0
        public ActionResult WysiwygWithForm()
        {
            var model = GetLayoutItem <Wysiwyg>();

            if (SitecoreUtils.EvaluateRules(model.RestrictionRule, model.InnerItem))
            {
                model.ControllerName = RenderingContext.Current.Rendering.Parameters["Controller"];
                model.ActionName     = RenderingContext.Current.Rendering.Parameters["Action"];
                return(View(model));
            }
            else
            {
                return(new EmptyResult());
            }
        }
        private SyncItem CreateSyncItem(string name, string database, string itemPath, string parentID, string templatePath)
        {
            SyncItem syncItem = new SyncItem
            {
                ID           = MainUtil.GetNewID(),
                DatabaseName = database,
                ItemPath     = String.Format("{0}/{1}", itemPath, name),
                ParentID     = parentID,
                Name         = name,
                MasterID     = Guid.Empty.ToString(),
                TemplateID   = TemplateIdResolver.Instance.GetTemplateId(templatePath),
                TemplateName = SitecoreUtils.GetTemplateName(templatePath)
            };

            syncItem.AddVersion(_config.BuildSyncVersion());
            return(syncItem);
        }
예제 #11
0
        private IEnumerable <RichText> FilterRichTextBasedOnRules(List <RichText> allRichTextItems)
        {
            var FilteredRichTextItems = allRichTextItems;

            foreach (var item in FilteredRichTextItems.Reverse <RichText>())
            {
                if (item.InnerItem.Fields[BaseComponent.RestrictionRuleId] != null)
                {
                    string rule = item.InnerItem.Fields[BaseComponent.RestrictionRuleId].Value;
                    if (!SitecoreUtils.EvaluateRules(rule, item.InnerItem))
                    {
                        FilteredRichTextItems.Remove(item);
                    }
                }
            }
            return(FilteredRichTextItems.AsEnumerable());
        }
예제 #12
0
        private IEnumerable <FeaturedItem> RemoveUnwantedImagesBasedOnRules(List <FeaturedItem> allImageItems)
        {
            var allFeaturedItems = allImageItems;

            foreach (var item in allFeaturedItems.Reverse <FeaturedItem>())
            {
                if (item.InnerItem.Fields[BaseComponent.RestrictionRuleId] != null)
                {
                    string rule = item.InnerItem.Fields[BaseComponent.RestrictionRuleId].Value;
                    if (!SitecoreUtils.EvaluateRules(rule, item.InnerItem))
                    {
                        allFeaturedItems.Remove(item);
                    }
                }
            }
            return(allFeaturedItems.AsEnumerable());
        }
예제 #13
0
        public ActionResult ShowWidget()
        {
            var model = GetLayoutItem <SideWidget>();
            BlueGreenContext userContext = new BlueGreenContext();

            if (SitecoreUtils.EvaluateRules(model.RestrictionRule, model.InnerItem))
            {
                foreach (var item in model.WidgetContents)
                {
                    item.isVisible = true;
                    if (SitecoreUtils.EvaluateRules(item.RestrictionRule, item.InnerItem))
                    {
                        if (item.WidgetLink != null)
                        {
                            item.WidgetLink.Url = UrlMapper.Map(item.WidgetLink.Url);
                        }
                        if (item.SubWidgetLink != null)
                        {
                            item.SubWidgetLink.Url = UrlMapper.Map(item.SubWidgetLink.Url);
                        }
                        if (item.SubWidgetText != null)
                        {
                            item.SubWidgetText = UpdateText(item.SubWidgetText, userContext);
                        }
                        if (item.SubWidgetLink != null && !string.IsNullOrEmpty(item.SubWidgetLink.Text))
                        {
                            item.SubWidgetLink.Text = UpdateText(item.SubWidgetLink.Text, userContext);
                        }
                    }

                    else
                    {
                        item.isVisible = false;
                    }
                }
            }
            else
            {
                model.WidgetContents = null;
                //model = null;
            }
            return(View(model));
        }
예제 #14
0
 /// <summary>
 /// Builds the relationship dropdown
 /// </summary>
 /// <returns></returns>
 public static List <SelectListItem> BuildStateDropdown()
 {
     return(State.BuildDropdown(SitecoreUtils.GetItem(STATE_GUID)));
 }
예제 #15
0
 /// <summary>
 /// Builds the relationship dropdown
 /// </summary>
 /// <returns></returns>
 public static List <SelectListItem> BuildCountryDropdown()
 {
     return(BuildDropdown(SitecoreUtils.GetItem(COUNTRY_GUID)));
 }
예제 #16
0
 /// <summary>
 /// Builds the dropwodn for USA Province states and Military
 /// </summary>
 /// <returns>Selceted List items</returns>
 public static List <SelectListItem> BuildUsaPossessionsDropdown()
 {
     return(BuildDropdown(SitecoreUtils.GetItem(STATE_POSSESSIONS_GUID)));
 }
예제 #17
0
 /// <summary>
 /// Builds the relationship dropdown
 /// </summary>
 /// <returns></returns>
 public static List <SelectListItem> BuildRelationshipDropdown()
 {
     return(Lookup.BuildDropdown(SitecoreUtils.GetItem(RELATIONSHIP_GUID)));
 }
예제 #18
0
        public ActionResult ChangePasswordProcess(ChangePassword changePassword)
        {
            var            context = new SitecoreContext();
            ChangePassword model   = context.GetCurrentItem <ChangePassword>();

            if (!changePassword.isPasswordPolicyFail && !Context.User.IsAuthenticated)
            {
                Response.Redirect(UrlMapper.Map(model.SiteSettings.SignInPage.Url));
                return(null);
            }

            model.isPasswordPolicyFail = changePassword.isPasswordPolicyFail;  //Reset the default value
            if (ModelState.IsValid)
            {
                if (changePassword.txtNewPassword.Contains(" "))
                {
                    ModelState.AddModelError("", Sitecore.Globalization.Translate.Text("Profile_PasswordInvalid"));
                }
                else
                {
                    SitecoreProfileService scProfileService = new SitecoreProfileService();

                    var membershipUser = scProfileService.GetCurrentMembershipUser();
                    if (membershipUser.ChangePassword(changePassword.txtCurrentPassword, changePassword.txtNewPassword))
                    {
                        EmailManager.UpdatePassword(membershipUser.UserName, membershipUser.Email);
                        if (changePassword.isPasswordPolicyFail)// Need to Complete the login Proces
                        {
                            Response.Redirect(UrlMapper.Map(model.SiteSettings.SignInWaitPage.Url));
                            return(null);
                        }
                        else
                        {
                            Session["isShowPasswordUpdated"] = true;
                            //  model.isShowPasswordUpdated = true;
                            return(Redirect(UrlMapper.Map(SitecoreUtils.GetPageUrl(SitecoreItemReferences.ChangePasswordPageId))));
                        }
                    }
                    else
                    {
                        MembershipUser user = Membership.GetUser(Context.User.Name, false);
                        if (user != null)
                        {
                            if (user.IsLockedOut)
                            {
                                var scUser = scProfileService.GetUser(Context.User.Name);
                                Components.EmailManager.ResetEmail(Context.User.Name, scUser.Profile.Email);
                                if (scUser != null && !scProfileService.CheckForPasswordLockedEmail(scUser))
                                {
                                    scUser.Profile.SetCustomProperty(SitecoreProfileService.PasswordLockedEmailId, "1");
                                    scUser.Profile.Save();
                                }
                                Session["SignInUiError"] = Sitecore.Globalization.Translate.Text("Profile_AccountLocked");
                                return(Redirect(UrlMapper.Map(model.SiteSettings.SignInPage.Url)));
                            }
                        }
                        ModelState.AddModelError("", Sitecore.Globalization.Translate.Text("CurrentPassword_Current_NotCorrect"));
                    }
                }
            }


            var errors = ModelState.Select(x => x.Value.Errors)
                         .Where(y => y.Count > 0)
                         .ToList();

            if (errors != null && errors.Count > 0)
            {
                Session["ChangePasswordError"] = errors;
            }
            if (changePassword.isPasswordPolicyFail)
            {
                return(Redirect(UrlMapper.Map(SitecoreUtils.GetPageUrl(SitecoreItemReferences.ChangePasswordPageId)) + "?PasswordRuleFail=true"));
            }
            else
            {
                return(Redirect(UrlMapper.Map(SitecoreUtils.GetPageUrl(SitecoreItemReferences.ChangePasswordPageId))));
            }
            //return View(model);
        }