當前位置: 首頁>>代碼示例>>C#>>正文


C# Models.RenderModel類代碼示例

本文整理匯總了C#中Umbraco.Web.Models.RenderModel的典型用法代碼示例。如果您正苦於以下問題:C# RenderModel類的具體用法?C# RenderModel怎麽用?C# RenderModel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RenderModel類屬於Umbraco.Web.Models命名空間,在下文中一共展示了RenderModel類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Frontpage

        public ActionResult Frontpage(RenderModel model)
        {
            IPublishedContent page = model.Content;
            FrontpageRenderModel newModel = new FrontpageRenderModel(page);

            newModel.Header = page.GetPropertyValue<string>("header");
            newModel.Bodytext = page.GetPropertyValue<IHtmlString>("bodyText");
            newModel.CreateReviewUserForm = new CreateReviewUserForm();

            var slideFolder = Umbraco.TypedMedia(page.GetPropertyValue<int>("slideFolder"));

            if (slideFolder != null)
            {
                List<Slide> slides = new List<Slide>();

                foreach (var image in slideFolder.Children)
                {
                    Slide s = new Slide();

                    s.ImageUrl = image.Url;
                    slides.Add(s);
                }
                newModel.Slides = slides;
            }

            //Do some stuff here, then return the base method
            return View(newModel);
        }
開發者ID:Tjornfelt,項目名稱:ScrumPower2,代碼行數:28,代碼來源:FrontpageController.cs

示例2: Index

        public override ActionResult Index(RenderModel model)
        {
            if (model.Content.TemplateId.Equals(Template.GetTemplateIdFromAlias("ProjectCreate")))
            {
                var member = Member.GetCurrentMember();
                if (member != null)
                {
                    if (Request.HttpMethod.Equals("GET"))
                        return CurrentTemplate(model);

                    var project = CreateProject(member);
                    if (project != null) return this.Redirect(umbraco.library.NiceUrl(project.Id));
                }

                return this.Redirect(Request.UrlReferrer.AbsoluteUri);
            }
            else
            {
                var id = Convert.ToInt32(Request.Params["id"]);
                var project = new Document(id);

                var member = Member.GetCurrentMember();
                var authorId = project.getProperty("author").Value;
                if (member != null && member.Id.Equals(authorId))
                {
                    if (Request.HttpMethod.Equals("GET"))
                        return base.View(model);

                    SaveProject(project, member);
                }

                return this.Redirect(umbraco.library.NiceUrl(id));
            }
        }
開發者ID:v-five,項目名稱:upgradeit,代碼行數:34,代碼來源:ProjectController.cs

示例3: Index

        /// <summary>
        /// The index <see cref="ActionResult"/>.
        /// </summary>
        /// <param name="model">
        /// The current render model.
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public override ActionResult Index(RenderModel model)
        {
            // Create the viewmodel
            var viewModel = ViewModelFactory.CreateProduct(model);

            return this.View(viewModel.ThemeViewPath("Product"), viewModel);
        }
開發者ID:Teknyc,項目名稱:Merchello,代碼行數:16,代碼來源:BazaarProductController.cs

示例4: Fruit

        public ActionResult Fruit(RenderModel model, string slug)
        {
            if (string.IsNullOrEmpty(slug))
            {
                return null;
            }
            else
            {
                foreach (var node in model.Content.Children)
                {
                    var potentialUrls = new List<string>();

                    var v = new VortoApiController();
                    var langs = (List<Our.Umbraco.Vorto.Models.Language>)v.GetInstalledLanguages();

                    foreach (var lang in langs)
                    {
                        var vortoValue = node.GetVortoValue<string>("fruitName", lang.IsoCode);
                        if (!string.IsNullOrEmpty(vortoValue))
                        {
                            potentialUrls.Add(vortoValue.ToUrlSegment());
                        }
                    }

                    if (potentialUrls.Contains(slug))
                    {
                        // match
                        return this.View("~/Views/Fruit.cshtml", this.CreateRenderModel(node));
                    }
                }
                return this.HttpNotFound();
            }
        }
開發者ID:Jeavon,項目名稱:FunWithVirtualContent,代碼行數:33,代碼來源:FruitsController.cs

示例5: Index

        //
        // GET: /Home/

        public override ActionResult Index(RenderModel model)
        {
            HomeModel customModel = new HomeModel(model);
            customModel.Message = "Hello world from HomeController";
            //customModel.SearchTerm = string.Empty;
            return CurrentTemplate(customModel);
        }
開發者ID:WebdevWizards,項目名稱:UmbracoMvc5.0,代碼行數:10,代碼來源:HomeController.cs

示例6: Index

 //
 // GET: /Movies/
 public override ActionResult Index(RenderModel model)
 {
     INode currentNode = Node.GetCurrent();
     var newsItem = ModelFactory.CreateModel<MoviesRazor.Models.NewsItem>(currentNode);
     newsItem.DisplayDate = newsItem.Date.ToString("dd MMMM yyyy");
     return CurrentTemplate(newsItem);
 }
開發者ID:pdebacker,項目名稱:UmbCodeGen_Example_Project_Razor,代碼行數:9,代碼來源:NewsItemController.cs

示例7: Index

        //
        // Note:
        //  the Index method handles the inital page GET request and the Ajax POST request
        //  on which a filtered result is returned. It is a simple approach to handle an Ajax
        //  request with little effort. A better option might be to use a SurfaceController.
        //  However, this example is about to show the Umbraco Code Generation possibilities
        //  and is not about showing the best practices using Umbraco MVC.
        //
        public override ActionResult Index(RenderModel model)
        {
            if (Request.HttpMethod.Equals("GET"))
            {
                INode currentNode = Node.GetCurrent();
                var moviesPage = new MoviesPage();

                moviesPage.Movies = ModelFactory.CreateModel<MoviesRazor.Models.Movies>(currentNode);

                INode genresNode = Node.GetNodeByXpath("//Genres");
                moviesPage.Genres = ModelFactory.CreateModel<Genres>(genresNode);

                return CurrentTemplate(moviesPage);
            }
            else
            {
                int genreId = int.Parse(Request.QueryString["genreId"]);
                INode currentNode = Node.GetCurrent();
                var movies = ModelFactory.CreateModel<MoviesRazor.Models.Movies>(currentNode);

                movies.MovieListItems = movies.MovieListItems.Where(l => l.Genre.NodeId == genreId).ToList();

                return PartialView("MoviesList", movies);
            }
        }
開發者ID:pdebacker,項目名稱:UmbCodeGen_Example_Project_Razor,代碼行數:33,代碼來源:MoviesController.cs

示例8: Container__5Childs_PageSize4__Page2_Returns_1_Item

        public void Container__5Childs_PageSize4__Page2_Returns_1_Item()
        {
			//1. Arrange
			var mSite = new Mock<ISiteRepository>();

			var mController = new Mock<ContainerBaseController>(mSite.Object) { CallBase = true }; //abstract class callBase
			var mContent = Arrange.Content("lorem parent page",
			new List<IPublishedContent>()
				{
					{ Arrange.Content("Lorem child page 1").Object },
					{ Arrange.Content("Ipsum child page 2").Object },
					{ Arrange.Content("Dolor child page 3").Object },
					{ Arrange.Content("Sit child page 4").Object },
					{ Arrange.Content("Consectetur child page 5").Object }
				});

			var renderModel = new RenderModel(mContent.Object, CultureInfo.InvariantCulture);

			//2.Act
			var result = mController.Object.Container(renderModel,
				p: 2,
				s: 4) as ViewResult;

			//3. Assert.
			Assert.IsTrue((result.Model as DynamicCollectionModel).TotalResults == 5, "Total results does not contain 5 items");
			Assert.IsTrue((result.Model as DynamicCollectionModel).Results.Count() == 1, "Resultset for page 2 does not contain the correct amount of items");
        }
開發者ID:joosthollander,項目名稱:Macaw.Umbraco.Foundation,代碼行數:27,代碼來源:ContainerBaseControllerTest.cs

示例9: SubMenu

 public ActionResult SubMenu(RenderModel model)
 {
     var contentSubMenu = model.Content.Children.FirstOrDefault(node => node.DocumentTypeAlias.Equals("ContentSubMenu"));
     if (contentSubMenu == null)
         return base.Index(model);
     return Redirect(contentSubMenu.Url);
 }
開發者ID:nicolasmetaye,項目名稱:DynamicLoopCompany,代碼行數:7,代碼來源:SubMenuController.cs

示例10: Index

        public override ActionResult Index(RenderModel model)
        {
            ContactOperationStatus operationStatus = _contactService.GetContact();
            ContactViewModel viewContact = new ContactViewModel(model);
            if (operationStatus.Status)
            {

                viewContact.InjectFrom(operationStatus.Contact);
                viewContact.ExistingUserName = operationStatus.Contact.UserName;
                viewContact.ExistingEmail = operationStatus.Contact.Email;
                if (!String.IsNullOrEmpty(Request["url"]))
                {
                    viewContact.Url = Request["url"];
                }
                if (!String.IsNullOrEmpty(Umbraco.Field("checkoutPage").ToString()))
                    viewContact.Url = Umbraco.Field("checkoutPage").ToString();

                viewContact.Titles = GetContactTitles();
                viewContact.Countries = GetCountries();
                viewContact.Status = operationStatus.Status;
                viewContact.Message = operationStatus.Message;
                return CurrentTemplate(viewContact);
            }
            return ReturnErrorView(operationStatus, model);
        }
開發者ID:jamesdrever,項目名稱:cpx,代碼行數:25,代碼來源:CpxMaintainContactController.cs

示例11: Index

        public ActionResult Index(RenderModel model, long p = 1)
        {
            var typedModel = model.Content.As<TextPageViewModel>();
            typedModel.Title = "[Overwritten] " + typedModel.Title;

            return CurrentView(typedModel);
        }
開發者ID:webmonger,項目名稱:umbraco-ditflo,代碼行數:7,代碼來源:UmbTextPageController.cs

示例12: Index

        public override ActionResult Index(RenderModel model)
        {
            INode currentNode = Node.GetCurrent();
            var cinemas = ModelFactory.CreateModel<Cinemas>(currentNode);

            return CurrentTemplate(cinemas);
        }
開發者ID:pdebacker,項目名稱:UmbCodeGen_Example_Project_Razor,代碼行數:7,代碼來源:CinemasController.cs

示例13: Index

        public override ActionResult Index(RenderModel model)
        {
            var products = model.Content.Children();
            var viewModel = new ProductFolderViewModel();
            
            foreach (var productContent in products)
            {
                var productModel = new ProductViewModel();

                productModel.Content= productContent.GetPropertyValue<string>("bodyText")
                    .ScrubHtml()
                    .Truncate(200, true, true);

                productModel.UrlName = productContent.UrlName;
                productModel.Title = productContent.Name;
                productModel.NumberOfComments = productContent.Descendants("Comment").Count();
                viewModel.Products.Add(productModel);
            }

            if (Request.IsAjaxRequest())
            {
                return Json(viewModel);
            }

            ViewBag.Model = viewModel;
            
            //Do some stuff here, then return the base method
            return base.Index(model);
        }
開發者ID:christofur,項目名稱:Umbraco-React-Starter-kit,代碼行數:29,代碼來源:ProductsFolderController.cs

示例14: Index

 //
 // GET: /Movies/
 public override ActionResult Index(RenderModel model)
 {
     INode currentNode = Node.GetCurrent();
     var news = ModelFactory.CreateModel<MoviesRazor.Models.NewsPage>(currentNode);
     FormatDates(news.NewsListItems);
     return CurrentTemplate(news);
 }
開發者ID:pdebacker,項目名稱:UmbCodeGen_Example_Project_Razor,代碼行數:9,代碼來源:NewsPageController.cs

示例15: Show

        /// <summary>
        /// Used to render the Members profile (virtual node)
        /// </summary>
        /// <param name="model"></param>
        /// <param name="membername">
        /// The slug which we use to look up the member
        /// </param>
        /// <param name="p"></param>
        /// <returns></returns>
        public ActionResult Show(RenderModel model, string membername, int? p = null)
        {
            var memPage = model.Content as DialogueVirtualPage;
            if (memPage == null)
            {
                throw new InvalidOperationException("The RenderModel.Content instance must be of type " + typeof(DialogueVirtualPage));
            }

            if (string.IsNullOrEmpty(membername))
            {
                return ErrorToHomePage(Lang("Errors.GenericMessage"));
            }

            using (UnitOfWorkManager.NewUnitOfWork())
            {
                var member = ServiceFactory.MemberService.GetUserBySlug(membername, true);
                var loggedonId = UserIsAuthenticated ? CurrentMember.Id : 0;
                var viewModel = new ViewMemberViewModel(model.Content)
                {
                    User = member,
                    LoggedOnUserId = loggedonId,
                    PageTitle = string.Concat(member.UserName, Lang("Members.ProfileTitle")),
                    PostCount = member.PostCount
                };

                // Get the topic view slug
                return View(PathHelper.GetThemeViewPath("MemberProfile"), viewModel);
            }
        }
開發者ID:ryan-buckman,項目名稱:Dialogue,代碼行數:38,代碼來源:DialogueMemberController.cs


注:本文中的Umbraco.Web.Models.RenderModel類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。