本文整理汇总了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);
}
示例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));
}
}
示例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);
}
示例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();
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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");
}
示例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);
}
示例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);
}
示例11: Index
public ActionResult Index(RenderModel model, long p = 1)
{
var typedModel = model.Content.As<TextPageViewModel>();
typedModel.Title = "[Overwritten] " + typedModel.Title;
return CurrentView(typedModel);
}
示例12: Index
public override ActionResult Index(RenderModel model)
{
INode currentNode = Node.GetCurrent();
var cinemas = ModelFactory.CreateModel<Cinemas>(currentNode);
return CurrentTemplate(cinemas);
}
示例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);
}
示例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);
}
示例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);
}
}