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


C# UmbracoHelper.Content方法代码示例

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


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

示例1: UmbracoEvents

        private List<BannerItem> UmbracoEvents()
        {
            var helper = new UmbracoHelper(UmbracoContext.Current);
            List<BannerItem> ue = new List<BannerItem>();
            IPublishedContent root = helper.Content(1068);
            IPublishedContent eventRoot = helper.Content(Convert.ToInt32(root.GetProperty("seminars").Value));
            foreach (var itm in eventRoot.Children.Where("Visible").Where("end >= DateTime.Now.Date").OrderBy("start"))
            {
                string input = itm.GetProperty("end").Value.ToString();
                DateTime dateTime;
                if (DateTime.TryParse(input, out dateTime))
                {
                    if (dateTime > DateTime.Now)
                    {
                        var bi = new BannerItem();
                        bi.title = itm.HasValue("subHeader") ? itm.GetProperty("subHeader").Value.ToString() : itm.Name;
                        if (itm.HasValue("country"))
                            bi.Country = itm.GetProperty("country").ToString();
                        bi.link = new entryLink
                        {
                            href = itm.Url,
                            target = "_self"
                        };
                        bi.published = bi.StartDateTime = "Seminar starts "+itm.GetProperty("start").Value.ToString().ToDate().ToShortDateString();

                        bi.updated = itm.UpdateDate.ToShortDateString();
                        bi.TypeOfContent = Enum.GetName(typeof(TypeOfContent),TypeOfContent.UmbracoEvent);

                        ue.Add(bi);
                    }
                }
            }
            return ue;
        }
开发者ID:Aikidokan,项目名称:www_marcbachraty_com,代码行数:34,代码来源:FbController.cs

示例2: Company

 public IPublishedContent Company()
 {
     var memberCompany = GetMember();
     var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
     // DKO: získá napojení na stránku firmy z nastavení uživatele v členské sekci
     return umbracoHelper.Content(memberCompany.Properties["CompanyPage"].Value);
 }
开发者ID:sandarina,项目名称:JobsplusUmbraco,代码行数:7,代码来源:JobTemplatesController.cs

示例3: ToBasketViewLineItem

        ///
        /// Utility extension to map a  to a BasketViewLine item.
        /// Notice that the ContentId is pulled from the extended data. The name can either
        /// be the Merchello product name via lineItem.Name or the Umbraco content page
        /// name with umbracoHelper.Content(contentId).Name
        ///
        ///
        ///The  to be mapped
        ///
        private static BasketViewLineItem ToBasketViewLineItem(this ILineItem lineItem)
        {
            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);

            var contentId = lineItem.ExtendedData.ContainsKey("umbracoContentId") ? int.Parse(lineItem.ExtendedData["umbracoContentId"]) : 0;

            var umbracoName = umbracoHelper.Content(contentId).Name;
            var merchelloProductName = lineItem.Name;

            return new BasketViewLineItem()
            {

                Key = lineItem.ExtendedData.GetProductKey(),// lineItem.Key,
                ContentId = contentId,
                ExtendedData = DictionaryToString(lineItem.ExtendedData),
                Name = merchelloProductName,
                //Name = umbracoName,
                Sku = lineItem.Sku,
                UnitPrice = lineItem.Price,
                TotalPrice = lineItem.TotalPrice,
                Quantity = lineItem.Quantity,
                Images = lineItem.ExtendedData.GetValue("images")

            };
        }
开发者ID:sychoow007,项目名称:oldlima,代码行数:34,代码来源:BasketViewModelExtensions.cs

示例4: TranslateSearchResultToBlogEntry

 public static BlogEntry TranslateSearchResultToBlogEntry(IPublishedContent results)
 {
     var helper = new UmbracoHelper(UmbracoContext.Current);
     var post = new BlogEntry();
     post.Title = results.GetPropertyValue<string>("uBlogsyContentTitle");
     var auth = helper.Content(results.GetPropertyValue<string>("uBlogsyPostAuthor"));
     post.Author = auth.uBlogsyAuthorName;
     var date = results.GetPropertyValue<string>("uBlogsyPostDate");
     post.Date = DateTime.Parse(date).ToString("D");
     var image = results.GetPropertyValue<string>("uBlogsyPostImage");
     if (!string.IsNullOrEmpty(image))
     post.Image =  helper.Media(image).umbracoFile;
     post.Summary = results.GetPropertyValue<string>("uBlogsyContentSummary");
     post.Url = results.Url();
     return post;
 }
开发者ID:Roballen,项目名称:RobSite,代码行数:16,代码来源:MyUmbracoHelper.cs

示例5: SendEmail

        public string SendEmail( int id ) 
        {
            // Parse the posted body string for my json object
            string body = null;
            using ( StreamReader reader = new StreamReader(HttpContext.Current.Request.InputStream) )
            {
                body = reader.ReadToEnd();
            }
            PostedData postedData = JsonConvert.DeserializeObject<PostedData>(body);

            // If testing is true, send to the entered test email address 
            if ( postedData.sendTestEmail && postedData.sendToAddress != String.Empty )
            {
                sendToAddress = postedData.sendToAddress;
            }
            else
            {
                sendToAddress = "[email protected]"; // this will be the [email protected] group (and should be set on a config file or via backend maybe?)
            }

            UmbracoHelper umbracoHelper = new UmbracoHelper(UmbracoContext.Current);

            IPublishedContent newsletter = umbracoHelper.Content(id);
            if ( newsletter != null )
            {
                string emailSubject = newsletter.GetPropertyValue("emailSubject").ToString();
                string emailContent = newsletter.GetPropertyValue("emailContent").ToString();
                string newsletterURL = newsletter.UrlAbsolute();

                if ( emailSubject == String.Empty || emailContent == String.Empty )
                {
                    resultStatus = "error";
                    resultMessage = "<strong>Email Subject or Content is empty.</strong> Please fix this before you are able to send the newsletter.";
                }
                else
                {
                    var msg = new MailMessage();
                    msg.To.Add(new MailAddress(sendToAddress));
                    msg.From = new MailAddress("[email protected]", "Stuart");
                    msg.Subject = emailSubject;
                    msg.IsBodyHtml = true;
                    
                    emailContent = emailContent.Replace(Environment.NewLine, "<br/>");

                    StringBuilder emailTemplate = new StringBuilder( System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath("~/App_Plugins/EmailNewsletter/BackOffice/views/Email.cshtml")) );
                   
                    string emailBody = emailTemplate.ToString()
                                .Replace("{{emailContent}}", emailContent)
                                .Replace("{{newsletterURL}}", newsletterURL);

                    msg.Body = emailBody;

                    using ( SmtpClient smtp = new SmtpClient() )
                    {
                        smtp.Send(msg);
                        resultStatus = "success";
                        resultMessage = "Email has been sent successfully.";
                    }
                } 
            }


            ReturnJSON result = new ReturnJSON
            {
                status = resultStatus,
                message = resultMessage
            };


            return JsonConvert.SerializeObject(result);

        }
开发者ID:57u,项目名称:umbraco.plugins.emailNewsletter,代码行数:72,代码来源:SendEmailController.cs

示例6: Replies

        public ActionResult Replies(int AdvertisementId)
        {
            TempData.Add("MemberCannotViewAdvertisement", false);
            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
            var advertisement = umbracoHelper.Content(AdvertisementId) as IPublishedContent;

            var company = Company();
            var companyName = company.Name;

            if (advertisement.Parent.Parent.Id != company.Id)
            {
                TempData.Add("MemberCannotViewAdvertisement", true);
                return CurrentUmbracoPage();
            }

            var model = new RepliesForm();
            model.AdvertisementId = AdvertisementId;
            var replies = GetReplies(AdvertisementId);
            model.Replies = replies;
            // označit reakce za zobrazené
            foreach (var reply in replies)
            {
                if (!reply.ViewDate.HasValue)
                {
                    reply.ViewDate = DateTime.Now;
                    _db.Save(reply);
                }
                else if (!reply.IsViewed)
                {
                    reply.IsViewed = true;
                    _db.Save(reply);
                }
            }
            model.CompanyName = companyName;
            /*
            model.Selection = new Dictionary<int,bool>();
            foreach(var reply in model.Replies)
            {
                model.Selection.Add(reply.Id, false);
            }*/
            model.SubmitAction = ESubmitAction.None;
            model.EmailText = @"Dobrý den,<br /><br />
            děkujeme za Váš zájem o práci v naší firmě. Bohužel, do užšího výběru postoupili jiní uchazeči, kteří lépe odpovídali našim požadavkům.
            Ceníme si Vašich vědomostí a dovedností a proto jsme si dovolili diskrétně uložit Váš životopis do naší databáze uchazečů o zaměstnání.
            Rádi se s Vámi spojíme, vznikne-li u nás pracovní pozice odpovídající Vaší kvalifikaci.<br /><br />
            Sledujte i nadále naše nabídky volných pracovních míst, které naleznete na webovém portálu http://jobsplus.cz/. <br /><br />
            Přejeme Vám mnoho osobních i pracovních úspěchů.<br /><br />S pozdravem,<br />" + companyName;

            return PartialView(model);
        }
开发者ID:sandarina,项目名称:JobsplusUmbraco,代码行数:50,代码来源:AdvertisementController.cs

示例7: Company

        public IPublishedContent Company()
        {
            /*
            var memberPicker = GetMemberId();

            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
            var company = umbracoHelper.TypedContentSingleAtXPath("//dtCompanyList").Children.Where("cMemberPicker =" + memberPicker);

            if (company != null && company.Count() > 0)
                return (IPublishedContent)umbracoHelper.TypedContent(Convert.ToInt32(company.First().Id));
            else
                return null;
             */
            var memberCompany = GetMember();
            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
            // DKO: získá napojení na stránku firmy z nastavení uživatele v členské sekci
            return umbracoHelper.Content(memberCompany.Properties["CompanyPage"].Value);
        }
开发者ID:sandarina,项目名称:JobsplusUmbraco,代码行数:18,代码来源:AdvertisementController.cs

示例8: GetResults

        public dynamic GetResults(UmbracoHelper umbracoHelper)
        {
            var sql = "exec spSelectDealerContentIDsWithinMiles @0, @1";
            var sqlArgs = new List<object>();
            sqlArgs.Add(this.Miles);
            sqlArgs.Add(this.ZipCode.Replace(" ", "").Trim());
            using (var connection = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["umbracoDbDSN"].ToString()))
            {
                connection.Open();
                var query = ApplicationContext.Current.DatabaseContext.Database.CreateCommand(connection, sql, sqlArgs.ToArray());
                var reader = query.ExecuteReader();

                var contentIDs = new Dictionary<int, decimal>();
                while (reader.Read()) {
                    contentIDs.Add(reader.GetInt32(0), Math.Round(Convert.ToDecimal(reader.GetDouble(1)), 2));
                }
                connection.Close();

                IEnumerable<IPublishedContent> content = ((DynamicPublishedContentList)umbracoHelper.Content(contentIDs.Select(c => c.Key))).AsQueryable<DynamicPublishedContent>();
                switch (this.ServiceType)
                {
                    case "Sales":
                        content = content.Where(c => c.AsDynamic().sales);
                        break;
                    case "Service":
                        content = content.Where(c => c.AsDynamic().service);
                        break;
                    case "Installation":
                        content = content.Where(c => c.AsDynamic().installation);
                        break;
                }

                return content.Select<dynamic, DealerSearchResult>(c => new DealerSearchResult() {
                    Url = c.Url,
                    Name = c.name,
                    Address1 = c.address.address1,
                    Address2 = c.address.address2 ?? "",
                    City = c.address.city,
                    State = c.address.state,
                    Zip = c.address.zip,
                    Phone = c.address.phone ?? "",
                    Lat = c.address.lat,
                    Lng = [email protected],
                    Services = GetServices(c),
                    Distance = contentIDs[c.Id],
                    DistanceString = string.Format("{0} - {1} miles", Math.Floor(contentIDs[c.Id]), Math.Ceiling(contentIDs[c.Id]))
                }).OrderBy(c => c.Distance).ToList();
            }
        }
开发者ID:CPE-Umbraco,项目名称:CPE,代码行数:49,代码来源:DealerSearchViewModel.cs


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