public ActionResult RenderTestimonials() { IPublishedContent homePage = CurrentPage.AncestorOrSelf("home"); string title = homePage.GetPropertyValue <string>("testimonialsTitle"); string introduction = homePage.GetPropertyValue("testimonialsIntro").ToString(); List <Testimonial> testimonials = new List <Testimonial>(); ArchetypeModel testimonialsList = homePage.GetPropertyValue <ArchetypeModel>("testimonialsList"); if (testimonialsList != null) { foreach (ArchetypeFieldsetModel testimonial in testimonialsList.Take(2)) { string name = testimonial.GetValue <string>("name"); string quote = testimonial.GetValue <string>("quote"); testimonials.Add(new Testimonial(name, quote)); } } Testimonials model = new Testimonials(title, introduction, testimonials); return(PartialView(PartialViewPath("_Testimonials"), model)); }
public static List <Dictionary <string, object> > MapArchetypeModel(ArchetypeModel archeTypeModel) { var mappedProps = new List <Dictionary <string, object> >(); foreach (var fieldSetIter in archeTypeModel.Fieldsets) { var mappedPropIter = new Dictionary <string, object>(); foreach (var propIter in fieldSetIter.Properties) { var propEditorAlias = propIter.PropertyEditorAlias; if (propEditorAlias.InvariantEquals("Umbraco.DropDown") || propEditorAlias.InvariantEquals("Umbraco.DropdownlistPublishingKeys")) { if (string.IsNullOrEmpty(Convert.ToString(propIter.Value))) { mappedPropIter[propIter.Alias] = propIter.Value; } else { var value = umbraco.library.GetPreValueAsString(Convert.ToInt32(propIter.Value)); mappedPropIter[propIter.Alias] = Regex.Replace(value, @"([a-z])([A-Z])", "$1-$2").ToLower(); } } else { mappedPropIter[propIter.Alias] = propIter.Value; } } mappedProps.Add(mappedPropIter); } return(mappedProps); }
public ActionResult RenderFeatured() { List <FeaturedItem> model = new List <FeaturedItem>(); IPublishedContent homePage = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "home").FirstOrDefault(); ArchetypeModel featuredItems = homePage.GetPropertyValue <ArchetypeModel>("featuredItems"); bool featuredItemsVisible = (bool)homePage.GetPropertyValue("visible"); if (featuredItemsVisible) { foreach (ArchetypeFieldsetModel fieldSet in featuredItems) { var mediaItem = fieldSet.GetValue <IPublishedContent>("image"); string imageUrl = mediaItem.Url; var pageId = fieldSet.GetValue <IPublishedContent>("page"); IPublishedContent linkedToPage = Umbraco.TypedContent(pageId.Id); string linkUrl = linkedToPage.Url; model.Add(new FeaturedItem(fieldSet.GetValue <string>("name"), fieldSet.GetValue <string>("category"), imageUrl, linkUrl)); } return(PartialView(PARTIAL_VIEW_FOLDER + "_Featured.cshtml", model)); } else { return(null); } }
public ActionResult RenderFeatured() { List <FeaturedItem> model = new List <FeaturedItem>(); // get to the home page IPublishedContent homePage = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "home").FirstOrDefault(); ArchetypeModel featuredItems = homePage.GetPropertyValue <ArchetypeModel>("featuredItems"); // get all those fieldsets and put them in featured items // https://github.com/kgiszewski/Archetype/issues/413 foreach (ArchetypeFieldsetModel fsm in featuredItems) { var mediaItem = fsm.GetValue <IPublishedContent>("image"); string imageUrl = mediaItem.Url; var linkedPage = fsm.GetValue <IPublishedContent>("page"); string pageUrl = linkedPage.Url; model.Add(new FeaturedItem() { Name = fsm.GetValue <string>("name"), Category = fsm.GetValue <string>("category"), ImageUrl = imageUrl, LinkUrl = pageUrl }); } return(PartialView(PARTIAL_VIEW_FOLDER + "_Featured.cshtml", model)); }
public List <FeaturedItem> GetFeaturedItemsModel() { //IPublishedContent homePage = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias.Equals(HOME_PAGE_DOC_TYPE_ALIAS, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); IPublishedContent homePage = _currentPage.AncestorOrSelf(_homeDocTypeAlias); List <FeaturedItem> model = new List <FeaturedItem>(); ArchetypeModel featuredItems = homePage.GetPropertyValue <ArchetypeModel>(_featuredItemsAlias); foreach (ArchetypeFieldsetModel fieldSet in featuredItems) { //name, categoryAlias, image, page string name = fieldSet.GetValue <string>(_nameAlias); string category = fieldSet.GetValue <string>(_categoryAlias); int imageId = fieldSet.GetValue <int>(_imageAlias); int pageId = fieldSet.GetValue <int>(_pageAlias); var mediaItem = _uHelper.Media(imageId); string imageUrl = mediaItem.Url; IPublishedContent linkedToPage = _uHelper.TypedContent(pageId); string linkUrl = linkedToPage.Url; model.Add(new FeaturedItem() { Name = name, Category = category, ImageUrl = imageUrl, LinkUrl = linkUrl }); } return(model); }
public void SetUp() { _archetype = ContentHelpers.Archetype; var content = ContentHelpers.FakeContent(123, "Fake Node 1", properties: new Collection<IPublishedProperty> { new FakePublishedProperty("myArchetypeProperty", _archetype, true) }); _content = new FakeModel(content); _propertyDescriptor = TypeDescriptor.GetProperties(_content)["TextString"]; _context = new FakeDittoValueResolverContext(_content, _propertyDescriptor); var mockedPropertyService = new Mock<PropertyValueService>(); mockedPropertyService.SetupSequence( i => i.Set(It.IsAny<IPublishedContent>(), It.IsAny<CultureInfo>(), It.IsAny<PropertyInfo>(), It.IsAny<object>(), It.IsAny<object>(), It.IsAny<DittoValueResolverContext>())) .Returns(new HtmlString("<p>This is the <strong>summary</strong> text.</p>")) .Returns("Ready to Enroll?") .Returns("{}"); _sut = new ArchetypeBindingService(mockedPropertyService.Object, new DittoAliasLocator()); }
public ActionResult RenderTestimonials() { // render blog, get the home page IPublishedContent homePage = CurrentPage.AncestorOrSelf("home"); // gets these two properties on the home page string title = homePage.GetPropertyValue <string>("testimonialsTitle"); // comes as HTML string introduction = homePage.GetPropertyValue("testimonialsIntroduction").ToString(); // get testimonials from Umbraco List <Testimonial> testimonials = new List <Testimonial>(); //populate the list we need to get the value ArchetypeModel testimonialList = homePage.GetPropertyValue <ArchetypeModel>("testimonialList"); if (testimonialList != null) { foreach (ArchetypeFieldsetModel testimonial in testimonialList.Take(MAXIMUM_TESTIMONIALS)) { string name = testimonial.GetValue <string>("name"); string quote = testimonial.GetValue <string>("quote"); testimonials.Add(new Testimonial(quote, name)); } } // pass testimonials to Testimonials model //it has created the model Testimonials model = new Testimonials(title, introduction, testimonials); return(PartialView(PARTIAL_VIEW_FOLDER + "_Testimonials.cshtml", model)); }
/// <summary> /// Renders the partials based on the model, partial path and given viewdata dictionary. /// </summary> /// <param name="htmlHelper">The HTML helper.</param> /// <param name="archetypeModel">The archetype model.</param> /// <param name="partialPath">The partial path.</param> /// <param name="viewDataDictionary">The view data dictionary.</param> /// <returns></returns> private static IHtmlString RenderPartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath, ViewDataDictionary viewDataDictionary) { var context = HttpContext.Current; if (archetypeModel == null || context == null) { return new HtmlString(""); } var sb = new StringBuilder(); var pathToPartials = "~/Views/Partials/Archetype/"; if (!string.IsNullOrEmpty(partialPath)) { pathToPartials = partialPath; } foreach (var fieldsetModel in archetypeModel) { var partial = pathToPartials + fieldsetModel.Alias + ".cshtml"; if (System.IO.File.Exists(context.Server.MapPath(partial))) { sb.AppendLine(htmlHelper.Partial(partial, fieldsetModel, viewDataDictionary).ToString()); } else { LogHelper.Info<ArchetypeModel>(string.Format("The partial for {0} could not be found. Please create a partial with that name or rename your alias.", context.Server.MapPath(partial))); } } return new HtmlString(sb.ToString()); }
//public LatestBlogPost GetLatestBlogPostModel() //{ // IPublishedContent page = CurrentPage.AncestorOrSelf("home"); // LatestBlogPost model = new LatestBlogPost() // { // Title = page.GetPropertyValue<string>("latestBlogPostsTitle"), // Introduction = page.GetPropertyValue<string>("latestBlogPostsIntroduction") // }; // return model; //} public ActionResult RenderTestimonials() { const string HOME_PAGE_DOC_TYPE_ALIAS = "home"; IPublishedContent page = CurrentPage.AncestorOrSelf(HOME_PAGE_DOC_TYPE_ALIAS); ArchetypeModel testimonialList = page.GetPropertyValue <ArchetypeModel>("testimonialList"); List <TestimonialModel> testimonials = new List <TestimonialModel>(); if (testimonials != null || testimonials.Count > 0) { foreach (ArchetypeFieldsetModel fieldSet in testimonialList.Take(MAX_TESTIMONIAL)) { testimonials.Add(new TestimonialModel() { Name = fieldSet.GetValue <string>("name"), Quote = fieldSet.GetValue <string>("quote") }); } } TestimonialsModel model = new TestimonialsModel() { Title = page.GetPropertyValue <string>("testimonialsTitle"), Introduction = page.GetPropertyValue <string>("testimonialsIntroduction"), Testimonials = testimonials }; return(PartialView(PartialViewPath("_Testimonials"), model)); }
public ActionResult RenderFeatured() { // create a model object which is a list of featured items List <FeaturedItem> model = new List <FeaturedItem>(); // goes to homePage, goes up the tree and down to find home, first instance IPublishedContent homePage = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "home").FirstOrDefault(); // you could use this: IPublishedContent homePage = CurrentPage.AncestorOrSelf("home"); // gets featuredItems property as an Archetype Model ArchetypeModel featuredItems = homePage.GetPropertyValue <ArchetypeModel>("featuredItems"); // loops through the Archetype model, through fieldsets there to get name, cat etc foreach (ArchetypeFieldsetModel fieldset in featuredItems) { string imageUrl = ""; int imageId = fieldset.GetValue <int>("image"); var mediaItem = Umbraco.Media(imageId); imageUrl = mediaItem.Url; int pageId = fieldset.GetValue <int>("page"); IPublishedContent linkedToPage = Umbraco.TypedContent(pageId); string linkUrl = linkedToPage.Url; // pass them through here model.Add(new FeaturedItem(fieldset.GetValue <string>("name"), fieldset.GetValue <string>("category"), imageUrl, linkUrl)); } return(PartialView(PARTIAL_VIEW_FOLDER + "_Featured.cshtml", model)); }
public ActionResult RenderTestimonials() { IPublishedContent homePage = CurrentPage.AncestorOrSelf("home"); string title = homePage.GetPropertyValue <string>("testimonialsTitle"); string introduction = homePage.GetPropertyValue("testimonialsIntroduction").ToString(); List <Testimonial> testimonials = new List <Testimonial>(); // get the testimonialList from Umbraco, type archetype ArchetypeModel testimonialList = homePage.GetPropertyValue <ArchetypeModel>("testimonialList"); if (testimonialList != null) { foreach (ArchetypeFieldsetModel testimonial in testimonialList.Take(MAXIMUM_TESTIMONIALS)) { string name = testimonial.GetValue <string>("name"); string quote = testimonial.GetValue <string>("quote"); testimonials.Add(new Testimonial(quote, name)); } } Testimonials model = new Testimonials(title, introduction, testimonials); return(PartialView("~/Views/Partials/Home/_Testimonials.cshtml", model)); }
public ActionResult RenderFeatured() { List <FeaturedItem> model = new List <FeaturedItem>(); //IPublishedContent homePage = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "home").FirstOrDefault(); IPublishedContent homePage = CurrentPage.AncestorOrSelf("home"); //Get property from the homepage //From ArchetypeMode model get all the fieldsets and put them into FeaturedItem class ArchetypeModel featuredItems = homePage.GetPropertyValue <ArchetypeModel>("featuredItems"); foreach (ArchetypeFieldsetModel fieldset in featuredItems) { string name = fieldset.GetValue <string>("name"); string category = fieldset.GetValue <string>("category"); //imageUrl int imageId = fieldset.GetValue <int>("image"); //gets the value of media picker var mediaItem = Umbraco.Media(imageId); string imageUrl = mediaItem.Url; //linkUrl int pageId = fieldset.GetValue <int>("page"); IPublishedContent page = Umbraco.TypedContent(pageId); string linkUrl = page.Url; model.Add(new FeaturedItem(name, category, imageUrl, linkUrl)); } return(PartialView(PartialViewPath("_Featured"), model)); }
// GET: Home public ActionResult RenderFeatured() { var model = new List <FeaturedItem>(); IPublishedContent home = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "home").FirstOrDefault(); ArchetypeModel featuredItems = home.GetPropertyValue <ArchetypeModel>("featuredItems"); foreach (ArchetypeFieldsetModel fieldset in featuredItems) { //Media Picker int imageId = fieldset.GetValue <int>("image"); var mediaItem = Umbraco.Media(imageId); string imageUrl = mediaItem.Url; //Content Picker int pageId = fieldset.GetValue <int>("page"); IPublishedContent linkedToPage = Umbraco.TypedContent(pageId); string linkUrl = linkedToPage.Url; //Textstring var name = fieldset.GetValue <string>("name"); model.Add(new FeaturedItem(name, fieldset.GetValue("category"), imageUrl, linkUrl)); } return(PartialView(PARTIAL_VIEW_FOLDER + "_Featured.cshtml", model)); }
public ActionResult RenderTestimonials() { IPublishedContent homePage = CurrentPage.AncestorOrSelf("home"); string title = homePage.GetPropertyValue <string>("testimonialsTitle"); string intro = homePage.GetPropertyValue("testimonialsIntroduction").ToString(); // don't want the html List <TestimonialModel> testimonials = new List <TestimonialModel>(); ArchetypeModel testimonialsList = homePage.GetPropertyValue <ArchetypeModel>("testimonialList"); if (testimonialsList != null) { foreach (ArchetypeFieldsetModel fsm in testimonialsList.Take(3)) { string name = fsm.GetValue <string>("name"); string quote = fsm.GetValue <string>("quote"); testimonials.Add(new TestimonialModel() { Name = name, Quote = quote }); } } TestimonialsModel model = new TestimonialsModel() { Title = title, Introduction = intro, Testimonials = testimonials }; return(PartialView(PARTIAL_VIEW_FOLDER + "_Testimonials.cshtml", model)); }
public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview) { var defaultValue = new ArchetypeModel(); if (source == null) { return(defaultValue); } var sourceString = source.ToString(); if (!sourceString.DetectIsJson()) { return(defaultValue); } using (var timer = DisposableTimer.DebugDuration <ArchetypeValueConverter>(string.Format("ConvertDataToSource ({0})", propertyType != null ? propertyType.PropertyTypeAlias : "null"))) { var archetype = ArchetypeHelper.Instance.DeserializeJsonToArchetype(sourceString, (propertyType != null ? propertyType.DataTypeId : -1), (propertyType != null ? propertyType.ContentType : null)); return(archetype); } }
private static IHtmlString RenderPartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath, ViewDataDictionary viewDataDictionary) { var context = HttpContext.Current; if (archetypeModel == null || context == null) { return(new HtmlString("")); } var sb = new StringBuilder(); var pathToPartials = "~/Views/Partials/Archetype/"; if (!string.IsNullOrEmpty(partialPath)) { pathToPartials = partialPath; } foreach (var fieldsetModel in archetypeModel) { var partial = pathToPartials + fieldsetModel.Alias + ".cshtml"; if (System.IO.File.Exists(context.Server.MapPath(partial))) { sb.AppendLine(htmlHelper.Partial(partial, fieldsetModel, viewDataDictionary).ToString()); } else { LogHelper.Info <ArchetypeModel>(string.Format("The partial for {0} could not be found. Please create a partial with that name or rename your alias.", context.Server.MapPath(partial))); } } return(new HtmlString(sb.ToString())); }
private void RetrieveAdditionalProperties(ref ArchetypeModel archetype, ArchetypePreValue preValue) { if (preValue == null) { return; } foreach (var fieldset in preValue.Fieldsets) { var fieldsetAlias = fieldset.Alias; foreach (var fieldsetInst in archetype.Fieldsets.Where(x => x.Alias == fieldsetAlias)) { foreach (var property in fieldset.Properties) { foreach (var propertyInst in fieldsetInst.Properties.Where(x => x.Alias == property.Alias)) { propertyInst.DataTypeGuid = property.DataTypeGuid.ToString(); Guid dataTypeGuid; if (Guid.TryParse(propertyInst.DataTypeGuid, out dataTypeGuid) == false) { throw new InvalidOperationException($"Could not parse DataTypeGuid as a guid: '{propertyInst.DataTypeGuid}'."); } var dataTypeDefinition = _dataTypeService.GetDataTypeDefinitionById(dataTypeGuid); if (dataTypeDefinition == null) { throw new NullReferenceException($"Could not find DataType with guid: '{dataTypeGuid}'"); } propertyInst.DataTypeId = dataTypeDefinition.Id; propertyInst.PropertyEditorAlias = property.PropertyEditorAlias; } } } } }
public void Init() { var archetypeJson = System.IO.File.ReadAllText("..\\..\\Data\\sample-1.json"); var converter = new ArchetypeValueConverter(); _archetype = (ArchetypeModel)converter.ConvertDataToSource(null, archetypeJson, false); }
public List <FeaturedItem> GetFeaturedItemsModel() { List <FeaturedItem> model = new List <FeaturedItem>(); //IPublishedContent homePage = Umbraco.AssignedContentItem.AncestorOrSelf(1); const int HOME_PAGE_POSITION_IN_PATH = 1; int homePageId = int.Parse(_currentPage.Path.Split(',')[HOME_PAGE_POSITION_IN_PATH]); IPublishedContent homePage = _uHelper.Content(homePageId); // get the value of hp - featured ArchetypeModel featuredItems = homePage.GetPropertyValue <ArchetypeModel>("featuredItems"); foreach (ArchetypeFieldsetModel fieldset in featuredItems) { var imageId = fieldset.GetValue <string>("image"); var mediaItem = _uHelper.Media(imageId); string imageUrl = mediaItem.Url; var pageId = fieldset.GetValue <string>("page"); IPublishedContent linkedToPage = _uHelper.TypedContent(pageId); string linkUrl = ""; if (linkedToPage != null) { linkUrl = linkedToPage.Url; } model.Add(new FeaturedItem(fieldset.GetValue <string>("name"), fieldset.GetValue <string>("category"), imageUrl, linkUrl)); } return(model); }
public void TearDown() { _sut = null; _archetype = null; _content = null; _propertyDescriptor = null; _context = null; }
public ArchetypeMappingExecutor(IMappingSession session, ArchetypeModel model, string dataType) { _session = session; _model = model; _type = typeof(T); _results = new List <T>(); _options = new MappingOptions(); _dataType = dataType; }
public void Null_ArchetypeModel_Throws_Exception() { TestDelegate code = () => { ArchetypeModel archetype = null; archetype.ToPublishedContentSet(); }; Assert.Throws <ArgumentNullException>(code); }
public static IPublishedContent ToPublishedContent(this ArchetypeFieldsetModel fieldset, ArchetypeModel archetype) { var contentSet = archetype.ToPublishedContentSet(); var first = contentSet .Cast<ArchetypePublishedContent>() .FirstOrDefault(x => x.ArchetypeFieldset == fieldset); return first ?? new ArchetypePublishedContent(fieldset); }
public static IEnumerable<ArchetypeSkill> GetFromContent(ArchetypeModel content) { return (from fieldset in content.Fieldsets where !fieldset.Disabled select new ArchetypeSkill { IconName = fieldset.GetValue<string>("icon"), Headline = fieldset.GetValue<string>("headline"), Description = fieldset.GetValue<string>("description") }); }
/// <summary> /// Renders the partials based on the model, partial path and given viewdata dictionary. /// </summary> /// <param name="htmlHelper">The HTML helper.</param> /// <param name="archetypeModel">The archetype model.</param> /// <param name="partialPath">The partial path.</param> /// <param name="viewDataDictionary">The view data dictionary.</param> /// <returns></returns> private static IHtmlString _renderPartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath, ViewDataDictionary viewDataDictionary) { var sb = new StringBuilder(); foreach (var fieldsetModel in archetypeModel) { sb.AppendLine(_renderPartial(htmlHelper, fieldsetModel, partialPath, viewDataDictionary).ToString()); } return(new HtmlString(sb.ToString())); }
public PlayerCharacterModel() { PlayerClass = new ClassModel(); Archetype = new ArchetypeModel(); Background = new BackgroundModel(); Race = new RaceModel(); Alignment = new AlignmentModel(); AbilityScores = new List <PcAbilityScoreModel>(); SavingThrows = new List <int>(); PlayerSkills = new List <int>(); }
public static List <T> ToList <T>(this ArchetypeModel model) { var items = new List <T>(); if (model is ArchetypeModel) { foreach (var fieldset in (model as ArchetypeModel)) { items.Add(fieldset.As <T>()); } } return(items); }
public void Basic_Model_Default() { var archetype = new ArchetypeModel(); var property = new PublishedPropertyMock("myProperty", archetype, true); var content = new PublishedContentMock { Properties = new[] { property } }; var model = content.As<BasicModel>(); Assert.IsNotNull(model); Assert.IsNotNull(model.MyProperty); Assert.IsInstanceOf<ArchetypeModel>(model.MyProperty); Assert.IsEmpty(model.MyProperty.Fieldsets); }
public List <FeaturedItem> GetFeaturedItemsModel() { List <FeaturedItem> model = new List <FeaturedItem>(); IPublishedContent homePage = _currentPage.AncestorOrSelf(_homeDocTypeAlias); ArchetypeModel featuredItems = homePage.GetPropertyValue <ArchetypeModel>(_featuredItemsAlias); foreach (ArchetypeFieldsetModel fieldSet in featuredItems) { string imageUrl = fieldSet.GetValue <IPublishedContent>(_imageAlias).Url; string linkUrl = fieldSet.GetValue <IPublishedContent>(_pageAlias).Url; model.Add(new FeaturedItem(fieldSet.GetValue <string>(_nameAlias), fieldSet.GetValue <string>(_categoryAlias), imageUrl, linkUrl)); } return(model); }
public ActionResult RenderGuide() { List <GuideItem> model = new List <GuideItem>(); IPublishedContent guidePage = CurrentPage.AncestorOrSelf("guide"); ArchetypeModel guideItems = guidePage.GetPropertyValue <ArchetypeModel>("guideItems"); foreach (ArchetypeFieldsetModel fieldset in guideItems) { string category = fieldset.GetValue <string>("category"); string description = fieldset.GetValue <string>("description"); model.Add(new GuideItem(category, description)); } return(PartialView("~/Views/Partials/Guide/_Guide.cshtml", model)); }
public static object MapCallouts(IUmbracoMapper mapper, IPublishedContent contentToMapFrom, string propName, bool isRecursive) { var result = new List <CalloutViewModel>(); ArchetypeModel archetypeModel = contentToMapFrom.GetPropertyValue <ArchetypeModel>(propName, isRecursive, null); if (archetypeModel != null) { var archetypeAsDictionary = archetypeModel .Select(item => item.Properties.ToDictionary(m => m.Alias, m => GetTypedValue(m), StringComparer.InvariantCultureIgnoreCase)) .ToList(); mapper.MapCollection(archetypeAsDictionary, result); } return(result); }
public PlayerCharacterModel() { AbilityScores = new List <PcAbilityScoreModel>(); Alignment = new AlignmentModel(); Archetype = new ArchetypeModel(); Background = new BackgroundModel(); PlayerClass = new ClassModel(); Equipment = new List <PcEquipmentModel>(); Features = new List <FeatureModel>(); Player = new PlayerModel(); Race = new RaceModel(); SavingThrows = new List <int>(); PlayerSkills = new List <int>(); Spells = new List <PcSpellModel>(); SpellLevels = new List <PcSpellLevelModel>(); Traits = new List <TraitModel>(); Treasure = new List <PcTreasureModel>(); }
public ActionResult RenderHome() { IPublishedContent homePage = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "home").FirstOrDefault(); int mapImageId = homePage.GetPropertyValue <int>("map"); string mapImageUrl = Umbraco.Media(mapImageId).Url; List <AirConditioner> airConditioners = new List <AirConditioner>(); ArchetypeModel airConditionersConfigs = homePage.GetPropertyValue <ArchetypeModel>("airConditioners"); foreach (ArchetypeFieldsetModel fieldset in airConditionersConfigs) { Guid id = fieldset.Id; string name = fieldset.GetValue <string>("name"); int maxTemperature = fieldset.GetValue <int>("maxTemperature"); int minTemperature = fieldset.GetValue <int>("minTemperature"); var temperatureScaleId = fieldset.GetValue <int>("temperatureScale"); string temperatureScale = Umbraco.GetPreValueAsString(temperatureScaleId); IPublishedContent image = fieldset.GetValue <IPublishedContent>("image"); string imageUrl = image.Url; var isVertical = int.Parse(image.GetPropertyValue("umbracoHeight").ToString()) > int.Parse(image.GetPropertyValue("umbracoWidth").ToString()); string positionX = fieldset.GetValue <string>("positionX"); string positionY = fieldset.GetValue <string>("positionY"); string width = fieldset.GetValue <string>("width"); string height = fieldset.GetValue <string>("height"); airConditioners.Add(new AirConditioner(id, name, maxTemperature, minTemperature, temperatureScale, imageUrl, positionX, positionY, width, height, isVertical)); } HomeModel homeModel = new HomeModel(mapImageUrl, airConditioners); return(PartialView(GetPartialView("_Home"), homeModel)); }
public ActionResult Index() { IPublishedContent services = CurrentPage; ArchetypeModel service = services.GetPropertyValue <ArchetypeModel>("products");//Name given to Archetype in DocType List <MicrodataModel> model = new List <MicrodataModel>(); foreach (ArchetypeFieldsetModel content in service.Where(x => x.Alias == "displayDemoProductsArchetype")) //Name given to Archetype in { foreach (ArchetypeFieldsetModel nestedContent in content.GetValue <ArchetypeModel>("productsForSale")) // Name given to nested Archetype in displayDemoProductsArchetype { string title = nestedContent.GetValue <string>("Title"); string description = nestedContent.GetValue <string>("Description"); string currencyCode = nestedContent.GetValue <string>("CurrencyCode"); string price = nestedContent.GetValue <string>("ItemPrice"); model.Add(new MicrodataModel(title, description, currencyCode, price)); } } return(PartialView($"{PartialViewFolder}{PartialSubFolder}pvProducts.cshtml", model)); }
public ActionResult RenderFeatured() { List <FeaturedItem> model = new List <FeaturedItem>(); IPublishedContent homePage = CurrentPage.AncestorOrSelf("home"); ArchetypeModel featuredItems = homePage.GetPropertyValue <ArchetypeModel>("featuredItems"); foreach (ArchetypeFieldsetModel fieldset in featuredItems) { string imageUrl = fieldset.GetValue <IPublishedContent>("image").Url; string pageId = fieldset.GetValue <string>("page"); IPublishedContent linkedToPage = Umbraco.TypedContent(pageId); string linkUrl = linkedToPage.Url; model.Add(new FeaturedItem(fieldset.GetValue <string>("name"), fieldset.GetValue <string>("category"), imageUrl, linkUrl)); } return(PartialView(PartialViewPath("_Featured"), model)); }
/// <summary> /// Retrieves additional metadata that isn't available on the stored model of an Archetype /// </summary> /// <param name="archetype">The Archetype to add the additional metadata to</param> /// <param name="preValue">The configuration of the Archetype</param> private void RetrieveAdditionalProperties(ref ArchetypeModel archetype, ArchetypePreValue preValue, PublishedContentType hostContentType = null) { foreach (var fieldset in preValue.Fieldsets) { var fieldsetAlias = fieldset.Alias; foreach (var fieldsetInst in archetype.Fieldsets.Where(x => x.Alias == fieldsetAlias)) { foreach (var property in fieldset.Properties) { var propertyAlias = property.Alias; foreach (var propertyInst in fieldsetInst.Properties.Where(x => x.Alias == propertyAlias)) { propertyInst.DataTypeGuid = property.DataTypeGuid.ToString(); propertyInst.DataTypeId = GetDataTypeByGuid(property.DataTypeGuid).Id; propertyInst.PropertyEditorAlias = property.PropertyEditorAlias; propertyInst.HostContentType = hostContentType; } } } } }
public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview) { var defaultValue = new ArchetypeModel(); if (source == null) return defaultValue; var sourceString = source.ToString(); if (!sourceString.DetectIsJson()) return defaultValue; using (var timer = DisposableTimer.DebugDuration<ArchetypeValueConverter>(string.Format("ConvertDataToSource ({0})", propertyType != null ? propertyType.PropertyTypeAlias : "null"))) { var archetype = ArchetypeHelper.Instance.DeserializeJsonToArchetype(sourceString, (propertyType != null ? propertyType.DataTypeId : -1), (propertyType != null ? propertyType.ContentType : null)); return archetype; } }
/// <summary> /// Retrieves additional metadata that isn't available on the stored model of an Archetype /// </summary> /// <param name="archetype">The Archetype to add the additional metadata to</param> /// <param name="preValue">The configuration of the Archetype</param> private void RetrieveAdditionalProperties(ref ArchetypeModel archetype, ArchetypePreValue preValue, PublishedContentType hostContentType = null) { foreach (var fieldset in preValue.Fieldsets) { var fieldsetAlias = fieldset.Alias; foreach (var fieldsetInst in archetype.Fieldsets.Where(x => x.Alias == fieldsetAlias)) { foreach (var property in fieldset.Properties) { var propertyAlias = property.Alias; foreach (var propertyInst in fieldsetInst.Properties.Where(x => x.Alias == propertyAlias)) { propertyInst.DataTypeGuid = property.DataTypeGuid.ToString(); propertyInst.DataTypeId = GetDataTypeByGuid(property.DataTypeGuid).Id; propertyInst.PropertyEditorAlias = property.PropertyEditorAlias; propertyInst.HostContentType = hostContentType; } } } } }
private int GetFieldsetCount(ArchetypeModel referenceArchetype, string fsAlias) { return referenceArchetype.Count(fs => fs.Alias.Equals(fsAlias)); }
/// <summary> /// Renders the partials based on the model, partial path and given viewdata dictionary. /// </summary> /// <param name="htmlHelper">The HTML helper.</param> /// <param name="archetypeModel">The archetype model.</param> /// <param name="partialPath">The partial path.</param> /// <param name="viewDataDictionary">The view data dictionary.</param> /// <returns></returns> private static IHtmlString RenderPartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath, ViewDataDictionary viewDataDictionary) { var context = HttpContext.Current; var sb = new StringBuilder(); foreach (var fieldsetModel in archetypeModel) { sb.AppendLine(RenderPartial(htmlHelper, fieldsetModel, partialPath, viewDataDictionary).ToString()); } return new HtmlString(sb.ToString()); }
/// <summary> /// Renders the archetype partials. /// </summary> /// <param name="htmlHelper">The HTML helper.</param> /// <param name="archetypeModel">The archetype model.</param> /// <returns></returns> public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel) { return _renderPartials(htmlHelper, archetypeModel, null, null); }
/// <summary> /// Retrieves the additional properties. /// </summary> /// <param name="archetype">The archetype.</param> /// <param name="preValue">The pre value.</param> private void RetrieveAdditionalProperties(ref ArchetypeModel archetype, ArchetypePreValue preValue) { foreach (var fieldset in preValue.Fieldsets) { var fieldsetAlias = fieldset.Alias; foreach (var fieldsetInst in archetype.Fieldsets.Where(x => x.Alias == fieldsetAlias)) { foreach (var property in fieldset.Properties) { var propertyAlias = property.Alias; foreach (var propertyInst in fieldsetInst.Properties.Where(x => x.Alias == propertyAlias)) { propertyInst.DataTypeGuid = property.DataTypeGuid.ToString(); propertyInst.DataTypeId = ExecutionContext.DatabasePersistence.GetNodeId( property.DataTypeGuid, UmbracoNodeObjectTypeIds.DataType); propertyInst.PropertyEditorAlias = property.PropertyEditorAlias; } } } } }
/// <summary> /// Renders the archetype partials. /// </summary> /// <param name="htmlHelper">The HTML helper.</param> /// <param name="archetypeModel">The archetype model.</param> /// <param name="partialPath">The partial path.</param> /// <returns></returns> public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath) { return RenderPartials(htmlHelper, archetypeModel, partialPath, null); }
/// <summary> /// Renders the archetype partials. /// </summary> /// <param name="htmlHelper">The HTML helper.</param> /// <param name="archetypeModel">The archetype model.</param> /// <param name="viewDataDictionary">The view data dictionary.</param> /// <returns></returns> public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, ViewDataDictionary viewDataDictionary) { return RenderPartials(htmlHelper, archetypeModel, null, viewDataDictionary); }
/// <summary> /// Renders the archetype partials. /// </summary> /// <param name="htmlHelper">The HTML helper.</param> /// <param name="archetypeModel">The archetype model.</param> /// <param name="partialPath">The partial path.</param> /// <param name="viewDataDictionary">The view data dictionary.</param> /// <returns></returns> public static IHtmlString RenderArchetypePartials(this HtmlHelper htmlHelper, ArchetypeModel archetypeModel, string partialPath, ViewDataDictionary viewDataDictionary) { return htmlHelper.RenderPartials(archetypeModel, partialPath, viewDataDictionary); }