Exemple #1
0
        public ActionResult RenderTestimonials()
        {
            IPublishedContent homePage = CurrentPage.AncestorOrSelf("home");

            string title        = homePage.GetPropertyValue <string>("testimonialsTitle");
            string introduction = homePage.GetPropertyValue("testimonialsIntro").ToString();

            List <Testimonial> testimonials     = new List <Testimonial>();
            ArchetypeModel     testimonialsList = homePage.GetPropertyValue <ArchetypeModel>("testimonialsList");

            if (testimonialsList != null)
            {
                foreach (ArchetypeFieldsetModel testimonial in testimonialsList.Take(2))
                {
                    string name  = testimonial.GetValue <string>("name");
                    string quote = testimonial.GetValue <string>("quote");

                    testimonials.Add(new Testimonial(name, quote));
                }
            }

            Testimonials model = new Testimonials(title, introduction, testimonials);

            return(PartialView(PartialViewPath("_Testimonials"), model));
        }
        //public LatestBlogPost GetLatestBlogPostModel()
        //{
        //    IPublishedContent page = CurrentPage.AncestorOrSelf("home");
        //    LatestBlogPost model = new LatestBlogPost()
        //    {
        //        Title = page.GetPropertyValue<string>("latestBlogPostsTitle"),
        //        Introduction = page.GetPropertyValue<string>("latestBlogPostsIntroduction")
        //    };
        //    return model;
        //}

        public ActionResult RenderTestimonials()
        {
            const string      HOME_PAGE_DOC_TYPE_ALIAS = "home";
            IPublishedContent page            = CurrentPage.AncestorOrSelf(HOME_PAGE_DOC_TYPE_ALIAS);
            ArchetypeModel    testimonialList = page.GetPropertyValue <ArchetypeModel>("testimonialList");

            List <TestimonialModel> testimonials = new List <TestimonialModel>();

            if (testimonials != null || testimonials.Count > 0)
            {
                foreach (ArchetypeFieldsetModel fieldSet in testimonialList.Take(MAX_TESTIMONIAL))
                {
                    testimonials.Add(new TestimonialModel()
                    {
                        Name  = fieldSet.GetValue <string>("name"),
                        Quote = fieldSet.GetValue <string>("quote")
                    });
                }
            }


            TestimonialsModel model = new TestimonialsModel()
            {
                Title        = page.GetPropertyValue <string>("testimonialsTitle"),
                Introduction = page.GetPropertyValue <string>("testimonialsIntroduction"),
                Testimonials = testimonials
            };

            return(PartialView(PartialViewPath("_Testimonials"), model));
        }
Exemple #3
0
        public ActionResult RenderTestimonials()
        {
            // render blog, get the home page
            IPublishedContent homePage = CurrentPage.AncestorOrSelf("home");

            // gets these two properties on the home page
            string title = homePage.GetPropertyValue <string>("testimonialsTitle");
            // comes as HTML
            string introduction = homePage.GetPropertyValue("testimonialsIntroduction").ToString();


            // get testimonials from Umbraco
            List <Testimonial> testimonials = new List <Testimonial>();

            //populate the list we need to get the value
            ArchetypeModel testimonialList = homePage.GetPropertyValue <ArchetypeModel>("testimonialList");

            if (testimonialList != null)
            {
                foreach (ArchetypeFieldsetModel testimonial in testimonialList.Take(MAXIMUM_TESTIMONIALS))
                {
                    string name  = testimonial.GetValue <string>("name");
                    string quote = testimonial.GetValue <string>("quote");
                    testimonials.Add(new Testimonial(quote, name));
                }
            }

            // pass testimonials to Testimonials model
            //it has created the model
            Testimonials model = new Testimonials(title, introduction, testimonials);

            return(PartialView(PARTIAL_VIEW_FOLDER + "_Testimonials.cshtml", model));
        }
        public ActionResult RenderTestimonials()
        {
            IPublishedContent homePage = CurrentPage.AncestorOrSelf("home");
            string            title    = homePage.GetPropertyValue <string>("testimonialsTitle");
            string            intro    = homePage.GetPropertyValue("testimonialsIntroduction").ToString(); // don't want the html

            List <TestimonialModel> testimonials     = new List <TestimonialModel>();
            ArchetypeModel          testimonialsList = homePage.GetPropertyValue <ArchetypeModel>("testimonialList");

            if (testimonialsList != null)
            {
                foreach (ArchetypeFieldsetModel fsm in testimonialsList.Take(3))
                {
                    string name  = fsm.GetValue <string>("name");
                    string quote = fsm.GetValue <string>("quote");
                    testimonials.Add(new TestimonialModel()
                    {
                        Name  = name,
                        Quote = quote
                    });
                }
            }

            TestimonialsModel model = new TestimonialsModel()
            {
                Title        = title,
                Introduction = intro,
                Testimonials = testimonials
            };

            return(PartialView(PARTIAL_VIEW_FOLDER + "_Testimonials.cshtml", model));
        }
Exemple #5
0
        public ActionResult RenderTestimonials()
        {
            IPublishedContent homePage     = CurrentPage.AncestorOrSelf("home");
            string            title        = homePage.GetPropertyValue <string>("testimonialsTitle");
            string            introduction = homePage.GetPropertyValue("testimonialsIntroduction").ToString();

            List <Testimonial> testimonials = new List <Testimonial>();

            // get the testimonialList from Umbraco, type archetype
            ArchetypeModel testimonialList = homePage.GetPropertyValue <ArchetypeModel>("testimonialList");

            if (testimonialList != null)
            {
                foreach (ArchetypeFieldsetModel testimonial in testimonialList.Take(MAXIMUM_TESTIMONIALS))
                {
                    string name  = testimonial.GetValue <string>("name");
                    string quote = testimonial.GetValue <string>("quote");
                    testimonials.Add(new Testimonial(quote, name));
                }
            }

            Testimonials model = new Testimonials(title, introduction, testimonials);

            return(PartialView("~/Views/Partials/Home/_Testimonials.cshtml", model));
        }