コード例 #1
0
		public static HtmlString RenderMortarItem(
			this HtmlHelper helper,
			MortarRow row,
			MortarItem item,
			string viewPath = "",
			string actionName = "",
			object model = null)
		{
			if (item == null || item.Value == null)
				return new HtmlString(string.Empty);

			if (!string.IsNullOrWhiteSpace(viewPath))
				viewPath = viewPath.TrimEnd('/') + "/";

			if (string.IsNullOrWhiteSpace(actionName))
				actionName = item.Value.DocumentTypeAlias;

			var controllerName = string.Concat(item.Value.DocumentTypeAlias, "Surface");

			if (SurfaceControllerHelper.SurfaceControllerExists(controllerName, actionName, true))
			{
				return helper.Action(actionName,
					controllerName,
					new
					{
						mortarModel = model ?? item.Value,
						mortarRow = row,
						mortarViewPath = viewPath
					});
			}

			return helper.Partial(viewPath + item.Value.DocumentTypeAlias, model ?? item.Value);
		}
コード例 #2
0
		public static HelperResult RenderMortarItems(
			this HtmlHelper helper,
			MortarRow row,
			Func<RenderMortarItemViewModel,
			HelperResult> template)
		{
			return new HelperResult(writer =>
			{
				var count = 0;
				foreach (var item in row.Items)
				{
					template(new RenderMortarItemViewModel(row, item, count++))
						.WriteTo(writer);
				}
			});
		}
コード例 #3
0
		public RenderMortarItemViewModel(MortarRow row, MortarItem item, int index)
		{
			Index = index;
			Item = item;
			Row = row;
		}