public List <Ship> GetAllShips() { var ships = new List <Ship>(); var items = Umbraco.ContentAtXPath("//ship").Where("Visible").OrderBy("createDate desc"); foreach (var item in items) { var ship = new Ship() { Id = item.id, Name = item.GetPropertyValue("shipName").ToString(), Desc = item.GetPropertyValue("shipDescription").ToString(), Code = item.GetPropertyValue("shipCode").ToString() }; foreach (var img in item.GetPropertyValue("shipImage")) { try { Console.WriteLine("Line 79"); Console.WriteLine(img.Name); ship.Images.Add(img.UrlName); } catch (Exception e) { Console.Write(e.ToString()); } } //newsItem.CreateDate = Convert.ToDateTime(item.CreateDate); ships.Add(ship); } return(ships); }
public JsonResult <IEnumerable <CarViewModel> > CarModels() { var carModels = Umbraco.ContentAtXPath("//carModel").Select(x => x as CarModel); var carViewModels = _mapper.Map <IEnumerable <CarViewModel> >(carModels); return(Json <IEnumerable <CarViewModel> >(carViewModels)); }
public List <ExchangeModel> GetAllBlogItems() { var blogNodes = (IPublishedContent)Umbraco.ContentAtXPath("//home//blog").FirstOrDefault(); var resp = blogNodes.Children <Blogpost>(); var modifiedList = resp.Select(x => new ExchangeModel(x.Name, x.WriterName)).ToList(); return(modifiedList.ToList()); }
public ActionResult RenderBookingForm() { BookingViewModel booking = new BookingViewModel(); if (TempData["nodeid"] != null) { try { string nodeId = TempData["nodeid"].ToString(); IPublishedContent node = Umbraco.TypedContent(nodeId); booking.EventDetails.Id = Convert.ToInt32(nodeId); booking.EventDetails.Name = node.Name; DateTime date = Convert.ToDateTime(node.GetProperty("date").Value); booking.EventDetails.Date_DateTime = date; booking.EventDetails.Date = Extension.Ordinal(Convert.ToInt32(date.ToString("%d"))) + " " + date.ToString("MMMM"); booking.EventDetails.Time = node.GetProperty("time").Value.ToString(); booking.EventDetails.Category = node.GetProperty("category").Value.ToString(); IPublishedContent location = Umbraco.TypedContent(node.GetProperty("locationPicker").Value.ToString()); booking.EventDetails.Address = location.GetProperty("address").Value.ToString(); booking.EventDetails.AvailableTickets = Convert.ToInt32(node.GetProperty("availableTickets").Value); booking.EventDetails.AllocatedTickets = Convert.ToInt32(node.GetProperty("allocatedTickets").Value); List <SelectListItem> sourceSelectList = new List <SelectListItem>(); foreach (var item in Umbraco.ContentAtXPath("//Events").First().GetPropertyValue("sourceDropDownList")) { sourceSelectList.Add(new SelectListItem() { Value = item.value, Text = item.value }); } booking.SourceItems = sourceSelectList; return(PartialView("BookingForm", booking)); } catch (Exception ex) { LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "Looking up Event with Id: - " + TempData["nodeid"].ToString(), new Exception(ex.Message)); return(PartialView("BookingForm", booking)); } } else { return(PartialView("BookingForm", booking)); } }
public ActionResult SubmitForm(ContactViewModel model) { bool success = false; if (ModelState.IsValid) { success = SendEmail(model); } var contactPage = Umbraco.ContentAtXPath("//contact").FirstOrDefault(); var successMessage = contactPage.Value <IHtmlString>("successMessage"); var errorMessage = contactPage.Value <IHtmlString>("errorMessage"); return(PartialView("/Views/Partials/Contact/result.cshtml", success ? successMessage : errorMessage)); }
public override ActionResult Index(ContentModel model) { var homePageModel = new HomePageModel(model.Content) { PastEvents = new List <EventsPage>(), UpcomingEvents = new List <EventsPage>() }; var episodesFolder = Umbraco.ContentSingleAtXPath($"//{EpisodesFolder.ModelTypeAlias}"); if (episodesFolder != null) { var episodes = episodesFolder.Children; foreach (var ep in episodes) { homePageModel.AllEpisodes.Add((Episode)ep); } homePageModel.LatestEpisode = Enumerable.OrderByDescending <Episode, DateTime>(homePageModel.AllEpisodes, x => x.PublishedDate).FirstOrDefault(); } var allEventPages = Umbraco.ContentAtXPath($"//{EventsPage.ModelTypeAlias}"); foreach (var page in allEventPages) { if (!page.IsVisible()) { continue; } if (!(page is EventsPage eventsPage)) { continue; } if (eventsPage.Part2StartDate >= DateTime.Today) { homePageModel.UpcomingEvents.Add(eventsPage); } else { homePageModel.PastEvents.Add(eventsPage); } } homePageModel.PastEvents = homePageModel.PastEvents.OrderByDescending(x => x.Part1StartDate).ToList(); return(CurrentTemplate(homePageModel)); }
public List <Ship> GetAllShips() { var ships = new List <Ship>(); var items = Umbraco.ContentAtXPath("//ship").Where("Visible").OrderBy("createDate desc"); foreach (var item in items) { var ship = new Ship(); ship.Name = item.GetPropertyValue("shipName").ToString(); ship.Desc = item.GetPropertyValue("shipDescription").ToString(); ship.Code = item.GetPropertyValue("shipCode").ToString(); //newsItem.CreateDate = Convert.ToDateTime(item.CreateDate); ships.Add(ship); } return(ships); }
private void AddDocumentTypesAndTemplates(StringBuilder html, IList <IContentType> documentTypes, IList <IContent> bluePrints, IList <IContentType> moduleTypes) { var docTypes = new StringBuilder(); docTypes.AppendLine("</div>"); var excludedTabs = new string[] { "Redirect", "SEO", "Visibility", "Markup", "Delete", "Auxiliary Folders" }; foreach (var documentType in documentTypes) { docTypes.AppendLine("<div class=\"umb-panel-group__details-check-title top-border\">"); docTypes.AppendLine($"<div class=\"umb-panel-group__details-check-name\" id=\"{documentType.Alias}\">"); docTypes.AppendLine("<h3>"); docTypes.AppendLine(documentType.Name); docTypes.AppendLine("</h3>"); docTypes.AppendLine("</div>"); // get URL of an example page var content = Umbraco.ContentAtXPath($"//{documentType.Alias}").FirstOrDefault(c => c.ContentType.Alias == documentType.Alias && c.TemplateId > 0); docTypes.AppendLine($"<div class=\"umb-panel-group__details-check-description\">"); docTypes.AppendLine($"{documentType.Description} {(content != null ? $"<a href=\"{content.Url}\" target=\"_blank\" class=\"btn-link -underline\">Example here</a>" : null)}"); docTypes.AppendLine("</div>"); docTypes.AppendLine($"<br />"); // document type structure var allowedParentDocTypes = documentTypes.Where(d => d.AllowedContentTypes.Any(c => c.Alias == documentType.Alias)).Select(d => d.Name).OrderBy(d => d); var allowedChildDocTypes = documentTypes.Where(d => documentType.AllowedContentTypes.Any(c => c.Alias == d.Alias)).Select(d => d.Name).OrderBy(d => d); docTypes.AppendLine($"<div>"); docTypes.AppendLine("<strong>Structure:</strong>"); docTypes.AppendLine("<ul>"); docTypes.AppendLine("<li>"); docTypes.AppendLine($"<strong>Allowed parent doc types:</strong> {(allowedParentDocTypes.Any() ? string.Join(", ", allowedParentDocTypes) : "none")}."); docTypes.AppendLine("</li>"); docTypes.AppendLine("<li>"); docTypes.AppendLine($"<strong>Allowed child doc types:</strong> {(allowedChildDocTypes.Any() ? string.Join(", ", allowedChildDocTypes) : "none")}."); docTypes.AppendLine("</li>"); docTypes.AppendLine("</ul>"); docTypes.AppendLine("</div>"); docTypes.AppendLine($"<br />"); // properties grouped by tabs docTypes.AppendLine($"<div>"); docTypes.AppendLine("<strong>Properties:</strong>"); docTypes.AppendLine("<ul>"); var tabs = documentType.PropertyGroups.Union(documentType.CompositionPropertyGroups).Where(p => !excludedTabs.Contains(p.Name)).OrderBy(p => p.SortOrder); foreach (var tab in tabs) { docTypes.AppendLine("<li>"); docTypes.AppendLine($"<strong>{tab.Name}</strong> tab:"); docTypes.AppendLine("<ul>"); foreach (var property in tab.PropertyTypes) { AddDocumentTypeProperty(docTypes, property, documentType, documentTypes, moduleTypes, bluePrints); } docTypes.AppendLine("</ul>"); docTypes.AppendLine("</li>"); } docTypes.AppendLine("</ul>"); docTypes.AppendLine("</div>"); docTypes.AppendLine("</div>"); } // remove last closing div tag (inc. 2 EOL chars) docTypes.Remove(docTypes.Length - 8, 8); AddUmbPanelGroup(html, "Document Types & Templates", "document-types-templates", docTypes.ToString()); }