当前位置: 首页>>代码示例>>C#>>正文


C# UmbracoHelper.TypedContent方法代码示例

本文整理汇总了C#中UmbracoHelper.TypedContent方法的典型用法代码示例。如果您正苦于以下问题:C# UmbracoHelper.TypedContent方法的具体用法?C# UmbracoHelper.TypedContent怎么用?C# UmbracoHelper.TypedContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UmbracoHelper的用法示例。


在下文中一共展示了UmbracoHelper.TypedContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAll

 public IEnumerable<Match> GetAll()
 {
     UmbracoHelper helper = new UmbracoHelper(UmbracoContext.Current);
     var today = DateTime.Today;
     var start = new DateTime(today.Month < 8?today.Year - 1: today.Year,8,1);
     var end = start.AddYears(1);
     return helper
         .TypedContent(1073)
         .Descendants("Match")
         .OrderBy(m => m.GetPropertyValue<DateTime>("dateAndTime"))
         .Select(c => new Match(c)) ;
 }
开发者ID:voordes,项目名称:MyVSC,代码行数:12,代码来源:MatchesController.cs

示例2: Index

        public ActionResult Index()
        {
            UmbracoHelper helper = new UmbracoHelper(this.UmbracoContext);
            var id = 1052;
            IPublishedContent content = helper.TypedContent(id);
            var productNodes = content.AncestorOrSelf(1).Descendants("product");
            List<ProductModel> productList = new List<ProductModel>();

            foreach (var p in productNodes)
            {
                productList.Add(new ProductModel
                {
                    ProductName = p.Name,
                    Category = p.GetPropertyValue("Category").ToString(), 
                    Price = p.GetPropertyValue("Price").ToString(),
                    Sku = p.GetPropertyValue("Sku").ToString(),
                    Description = p.GetPropertyValue("Description").ToString(),
                    Image = p.GetPropertyValue("Image").ToString()
                });
            }
           
            return PartialView("ProductList", model: new ProductVM { ProductList = productList });
        }
开发者ID:WebdevWizards,项目名称:UmbracoMvc5.0,代码行数:23,代码来源:ProductSurfaceController.cs

示例3: GetAllNews

 ///umbraco/Api/news/getallnews?parent=1053
 public IEnumerable<NewsItem> GetAllNews(int parent,int page)
 {
     UmbracoHelper help = new UmbracoHelper(UmbracoContext);
     int numberInPage = 2;
     if(page == 0) { page = numberInPage; }
     int count = help.TypedContent(parent).Children().Where("Visible").Count();
     return help.TypedContent(parent).Children().Where("Visible").Skip((numberInPage - page) + numberInPage).Select(obj => new NewsItem()
     {
         Name = obj.Name,
         Id = obj.Id
         //BodyText = obj.GetPropertyValue(bodyText)
     });
 }
开发者ID:wjonesy,项目名称:Umbraco150722,代码行数:14,代码来源:NewsController.cs

示例4: UpdateProjectExamineIndex

 private void UpdateProjectExamineIndex(IEntity item)
 {
     var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
     var content = umbracoHelper.TypedContent(item.Id);
     var downloads = Utils.GetProjectTotalDownloadCount(content.Id);
     UpdateProjectExamineIndex(content, downloads);
 }
开发者ID:KerwinMa,项目名称:OurUmbraco,代码行数:7,代码来源:ProjectIndexer.cs

示例5: Post

        // POST umbraco/api/umbcontact/post
        public HttpResponseMessage Post([FromBody]UmbContactMail message)
        {
            // Return errors if the model validation fails
            // The model defines validations for empty or invalid email addresses
            // See the UmbContactMail class below
            if (ModelState.IsValid == false)
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState.First().Value.Errors.First().ErrorMessage);

            // In order to allow editors to configure the email address where contact
            // mails will be sent, we require that to be set in a property with the
            // alias umbEmailTo - This property needs to be sent into this API call
            var umbraco = new UmbracoHelper(UmbracoContext);
            var content = umbraco.TypedContent(message.SettingsNodeId);

            if (content == null)
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest,
                          "Please provide a valid node Id on which the umbEmailTo property is defined.");

            var mailTo = content.GetPropertyValue<string>("umbEmailTo");

            if (string.IsNullOrWhiteSpace(mailTo))
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest,
                          string.Format("The umbEmailTo property on node {0} (Id {1}) does not exists or has not been filled in.",
                          content.Name, content.Id));

            // If we have a valid email address to send the email to, we can try to
            // send it. If the is an error, it's most likely caused by a wrong SMTP configuration
            return TrySendMail(message, mailTo)
                ? new HttpResponseMessage(HttpStatusCode.OK)
                : Request.CreateErrorResponse(HttpStatusCode.ServiceUnavailable,
                          "Could not send email. Make sure the server settings in the mailSettings section of the Web.config file are configured correctly. For a detailed error, check ~/App_Data/Logs/UmbracoTraceLog.txt.");
        }
开发者ID:biapar,项目名称:Documento,代码行数:33,代码来源:UmbContactController.cs

示例6: Index

        public ActionResult Index()
        {
            var help = new UmbracoHelper(UmbracoContext.Current);
            var url =Request.Url.AbsolutePath.Replace("sitemap.xml", "");
            var model = uQuery.GetNodeByUrl(url);

            return View("~/Views/Sitemap.cshtml", help.TypedContent(model.Id));
        }
开发者ID:Kimtho,项目名称:USearchEngineSitemap,代码行数:8,代码来源:SitemapController.cs

示例7: GetAllCategories

        public IEnumerable<ICategory> GetAllCategories()
        {
            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
            var content = umbracoHelper.TypedContent(int.Parse(ConfigurationManager.AppSettings["deliProjectRoot"]));
            var contents = content.Descendants().Where(x => x.DocumentTypeAlias == "ProjectGroup");

            return contents.ToICategoryList();
        }
开发者ID:larrynPL,项目名称:OurUmbraco,代码行数:8,代码来源:UmbracoCategoryProvider.cs

示例8: GetListing

        /// <summary>
        /// get project listing based on ID
        /// </summary>
        /// <param name="id"></param>
        /// <param name="optimized"></param>
        /// <param name="projectKarma"></param>
        /// <returns></returns>
        public IListingItem GetListing(int id, bool optimized = false, int projectKarma = -1)
        {
            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
            var content = umbracoHelper.TypedContent(id);

            if (content != null)
                return GetListing(content, optimized, projectKarma);

            throw new NullReferenceException("Content is Null cannot find a node with the id:" + id);
        }
开发者ID:ClaytonWang,项目名称:OurUmbraco,代码行数:17,代码来源:NodeListingProvider.cs

示例9: GetNews

 ///umbraco/Api/news/getnews?id=1054
 public NewsItem GetNews(int id)
 {
     UmbracoHelper help = new UmbracoHelper(UmbracoContext);
     var content = help.TypedContent(id);
     return new NewsItem
     {
         Name = content.Name,
         Id = content.Id
     };
 }
开发者ID:wjonesy,项目名称:Umbraco150722,代码行数:11,代码来源:NewsController.cs

示例10: GetStatus

 //Gets a single status doc based on the id
 public Status GetStatus(int id)
 {
     UmbracoHelper help = new UmbracoHelper(UmbracoContext);
     var content  = help.TypedContent(id);
     return new Status
     {
         Id = content.Id,
         Title = content.Name,
         Message = content.GetPropertyValue<string>(MessagePropertyAlias)
     };
 }
开发者ID:RichardIke,项目名称:UmbracoSinglePageCrudApp,代码行数:12,代码来源:StatusApiController.cs

示例11: GetAllStatuses

 //Fetches all status docs under the specified parent
 public IEnumerable<Status> GetAllStatuses(int parentId)
 {
     UmbracoHelper help = new UmbracoHelper(UmbracoContext);
     return help.TypedContent(parentId)
         .Children
         .Where(c => c.DocumentTypeAlias == StatusDocTypeAlias)
         .Select(obj => new Status()
     {
         Title = obj.Name,
         Message = obj.GetPropertyValue<string>(MessagePropertyAlias),Id = obj.Id
     });
 }
开发者ID:RichardIke,项目名称:UmbracoSinglePageCrudApp,代码行数:13,代码来源:StatusApiController.cs

示例12: GetCategory

        public ICategory GetCategory(int id)
        {
            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
            var content = umbracoHelper.TypedContent(id);

            if (content.DocumentTypeAlias != "ProjectGroup")
            {
                throw new Exception("Content is not of the correct type");
            }

            return content.ToICategory();
        }
开发者ID:larrynPL,项目名称:OurUmbraco,代码行数:12,代码来源:UmbracoCategoryProvider.cs

示例13: ConvertPropertyValue

        /// <summary>
        /// Attempts to convert the value specified into a useable value on the front-end
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public Attempt<object> ConvertPropertyValue(object value)
        {
            if (UmbracoContext.Current != null && value != null && value.ToString().Length > 0)
            {
                var data = value.ToString();
                var nodeIds = XmlHelper.CouldItBeXml(data) ? uQuery.GetXmlIds(data) : uQuery.ConvertToIntArray(uQuery.GetCsvIds(data));

                var helper = new UmbracoHelper(UmbracoContext.Current);
                return new Attempt<object>(true, helper.TypedContent(nodeIds));
            }

            return Attempt<object>.False;
        }
开发者ID:bokmadsen,项目名称:uComponents,代码行数:18,代码来源:CheckBoxTreePropertyEditorValueConverter.cs

示例14: GetNearest

        public IEnumerable<ExpandoObject> GetNearest(string address, int parentId, int docTypeFilter, string locationPropAlias, int numberOfSearchResults)
        {
            UmbracoHelper help = new UmbracoHelper(UmbracoContext);

            var nodesToSearchThrough = help.TypedContent(parentId)
                .Descendants().Where(c => c.DocumentTypeId == docTypeFilter).Where("Visible");

            var distanceunit = DistanceUnits.Kilometers;

            var items = new List<GeoItem>();
            var searchLocation = new Location();

            var r = GoogleGeoCoder.CallGeoWS(address);

            searchLocation = new Location(r.Results[0].Geometry.Location.Lat, r.Results[0].Geometry.Location.Lng);

            foreach (var node in nodesToSearchThrough) {

              var itemLocation = new Location(
                    Convert.ToDouble(node.GetProperty(locationPropAlias).Value.ToString().Split(',')[0], Utility.NumberFormatInfo),
                    Convert.ToDouble(node.GetProperty(locationPropAlias).Value.ToString().Split(',')[1], Utility.NumberFormatInfo));

              items.Add(new GeoItem(node,itemLocation,searchLocation.DistanceBetween(itemLocation,distanceunit)));
               }

            items.Sort(new GeoItemComparer());

            var retval = new List<ExpandoObject>();
            foreach (GeoItem geo in items.Take(numberOfSearchResults))
            {
                IPublishedContent node = ((IPublishedContent)geo.Node);

                var obj = new ExpandoObject() as IDictionary<string, Object>;

                obj.Add("Distance", geo.Distance);
                obj.Add("Latitude", geo.Location.Latitude);
                obj.Add("Longitude", geo.Location.Longitude);

                obj.Add("Name", node.Name);
                obj.Add("Url", node.Url);

                foreach (var nodeProp in node.Properties)
                {
                    obj.Add(nodeProp.Alias, nodeProp.Value);
                }

                retval.Add((ExpandoObject)obj);
            }
            return retval;
        }
开发者ID:TimGeyssens,项目名称:LocatorRazorStyle,代码行数:50,代码来源:LocatorApiController.cs

示例15: CountryCost

        public CountryCost(IPublishedContent costCountry, string goalCurrency)
        {
            if (costCountry == null)
            {
                throw new PatentVistaMissingValueException("Het kostenland is niet ingevuld! Waarschijnlijk ben je vergeten om dit land aan een kostenland te koppelen");
            }

            if (!costCountry.DocumentTypeAlias.Equals("Landkosten"))
            {
                throw new ArgumentException("CountryCost object must receive a Landkosten node instead of a {0} node", costCountry.DocumentTypeAlias);
            }

            if (costCountry.GetProperty("valutacode").Value != null)
            {
                var umbHelper = new UmbracoHelper(UmbracoContext.Current);
                object valutaCode = costCountry.GetProperty("valutacode").Value;
                if (valutaCode == null || valutaCode == "")
                {
                    throw new PatentVistaMissingValueException(String.Format("De valutacode voor kostenland {0} is niet ingevuld", costCountry.Name));
                }
                IPublishedContent valutaItem = umbHelper.TypedContent(valutaCode.ToString());

                if (valutaItem == null)
                {
                    throw new PatentVistaMissingValueException(String.Format("Er hangt voor kostenland {0} misschien wat oude data in de Umbraco cache. Koppel {0} " +
                                                                             "(het kostenland, niet het land) opnieuw aan een valuta en save en publiceer {0} " +
                                                                             "  opnieuw", costCountry.Name));
                }

                currencyCode = valutaItem.Name;
            }

            localDollarRate = CurrencyHelper.FindDollarRate(currencyCode);
            goalDollarRate = CurrencyHelper.FindDollarRate(goalCurrency);

            onlineIndienen = UmbracoFieldHelper.GetIntField(costCountry, "onlineIndienen");
            eersteIndiening = UmbracoFieldHelper.GetIntField(costCountry, "eersteIndiening");
            extraClaimkostenVanafClaim10 = UmbracoFieldHelper.GetIntField(costCountry, "extraClaimkostenVanafClaim10");
            nieuwheidsonderzoekNationaalType = UmbracoFieldHelper.GetIntField(costCountry, "nieuwheidsonderzoekNationaalType");
            nieuwheidsonderzoekInternationaalType = UmbracoFieldHelper.GetIntField(costCountry, "nieuwheidsonderzoekInternationaalType");
            examination = UmbracoFieldHelper.GetIntField(costCountry, "examination");
            kostenVerlening = UmbracoFieldHelper.GetIntField(costCountry, "kostenVerlening");
            publicatiekostenVerlening = UmbracoFieldHelper.GetIntField(costCountry, "publicatiekostenVerlening");

            for (int i = 1; i <= 20; i++)
            {
                jaren.Add(i, UmbracoFieldHelper.GetIntField(costCountry, String.Format("jaar{0}", i)));
            }
        }
开发者ID:rubenski,项目名称:pvista,代码行数:49,代码来源:CountryCost.cs


注:本文中的UmbracoHelper.TypedContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。