public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var jo = JToken.ReadFrom(reader); var val = jo.ToObject <string>(); return(val == null ? null : Udi.Parse(val, true)); }
public Sponsor GetSponsor(int sponsorId) { var cs = Services.ContentService; var sponsor = cs.GetById(sponsorId); Sponsor res = new Sponsor { Id = sponsor.Id, SponsorName = sponsor.Properties["sponsorName"].Value.ToString() }; try { string guid = sponsor.Properties["logo"].Value.ToString(); var udi = Udi.Parse(guid); var media = Umbraco.GetIdForUdi(udi); var content = Umbraco.Media(media); var imgPath = content.Url; res.Logo = imgPath; } catch (NullReferenceException e) { Console.WriteLine(e.Message); } return(res); }
public void UpdateSearchAppliance(ICollection <ISearchIndexEntry> entries, ICollection <UpdateItemReference> updatedItems = null, ISearchConfig config = null, bool waitForCompletion = false) { var currentEntries = entries; var currentItems = updatedItems ?? entries.Select(e => new UpdateItemReference { ContentUdi = Udi.Parse(e.ObjectID) }).ToList(); var currentConfig = config as IAlgoliaSearchConfig ?? _algoliaSearchConfig; if (waitForCompletion) { try { var src = new CancellationTokenSource(); UpdateSearchAppliance(src.Token, currentEntries, currentItems, currentConfig).Wait(); } catch (Exception ex) { _logger.Error <AlgoliaSearchApplianceService>(ex, "Could not update search appliance"); } } else { HostingEnvironment.QueueBackgroundWorkItem(async t => { try { await UpdateSearchAppliance(t, currentEntries, currentItems, currentConfig); } catch (Exception ex) { _logger.Error <AlgoliaSearchApplianceService>(ex, "Could not update search appliance"); } }); } }
private static List <MultipleTreeNodePickerConverted> ConvertMultiNodeTreePicker(object value) { var returnList = new List <MultipleTreeNodePickerConverted>(); if (value != null && !string.IsNullOrEmpty(value.ToString())) { var udis = value.ToString().Split(','); foreach (var stringUdi in udis) { var udi = Udi.Parse(stringUdi); var content = Current.Services.ContentService.GetById(((GuidUdi)udi).Guid); if (content != null) { returnList.Add(new MultipleTreeNodePickerConverted { Name = content.Name, Icon = content.ContentType.Icon, EditingLink = "/umbraco#/content/content/edit/" + content.Id }); } } } return(returnList); }
public Club GetClub(int clubId) { var club = cs.GetById(clubId); List <Team> teams = tc.GetTeams(club.Id); Club res = new Club { Id = club.Id, Name = club.Properties["clubTitle"].Value.ToString(), Description = club.Properties["clubDescription"].Value.ToString(), Teams = teams }; if (club.ContentType.Alias == "club") { try { string guid = club.Properties["clubLogo"].Value.ToString(); var udi = Udi.Parse(guid); var media = Umbraco.GetIdForUdi(udi); var content = Umbraco.Media(media); var imgPath = content.Url; res.ClubLogo = imgPath; } catch (NullReferenceException e) { Console.WriteLine(e.Message); } return(res); } return(new Club()); }
public void RootUdiTest() { var stringUdi = new StringUdi(Constants.UdiEntityType.AnyString, string.Empty); Assert.IsTrue(stringUdi.IsRoot); Assert.AreEqual("umb://any-string/", stringUdi.ToString()); var guidUdi = new GuidUdi(Constants.UdiEntityType.AnyGuid, Guid.Empty); Assert.IsTrue(guidUdi.IsRoot); Assert.AreEqual("umb://any-guid/00000000000000000000000000000000", guidUdi.ToString()); var udi = Udi.Parse("umb://any-string/"); Assert.IsTrue(udi.IsRoot); Assert.IsInstanceOf <StringUdi>(udi); udi = Udi.Parse("umb://any-guid/00000000000000000000000000000000"); Assert.IsTrue(udi.IsRoot); Assert.IsInstanceOf <GuidUdi>(udi); udi = Udi.Parse("umb://any-guid/"); Assert.IsTrue(udi.IsRoot); Assert.IsInstanceOf <GuidUdi>(udi); }
public void StringEncodingTest() { // absolute path is unescaped var uri = new Uri("umb://" + Constants.UdiEntityType.AnyString + "/this%20is%20a%20test"); Assert.AreEqual("umb://" + Constants.UdiEntityType.AnyString + "/this is a test", uri.ToString()); Assert.AreEqual("umb://" + Constants.UdiEntityType.AnyString + "/this%20is%20a%20test", uri.AbsoluteUri); Assert.AreEqual("/this%20is%20a%20test", uri.AbsolutePath); Assert.AreEqual("/this is a test", Uri.UnescapeDataString(uri.AbsolutePath)); Assert.AreEqual("%2Fthis%20is%20a%20test", Uri.EscapeDataString("/this is a test")); Assert.AreEqual("/this%20is%20a%20test", Uri.EscapeUriString("/this is a test")); var udi = Udi.Parse("umb://" + Constants.UdiEntityType.AnyString + "/this%20is%20a%20test"); Assert.AreEqual(Constants.UdiEntityType.AnyString, udi.EntityType); Assert.IsInstanceOf <StringUdi>(udi); var stringEntityId = udi as StringUdi; Assert.IsNotNull(stringEntityId); Assert.AreEqual("this is a test", stringEntityId.Id); Assert.AreEqual("umb://" + Constants.UdiEntityType.AnyString + "/this%20is%20a%20test", udi.ToString()); var udi2 = new StringUdi(Constants.UdiEntityType.AnyString, "this is a test"); Assert.AreEqual(udi, udi2); var udi3 = new StringUdi(Constants.UdiEntityType.AnyString, "path to/this is a test.xyz"); Assert.AreEqual("umb://" + Constants.UdiEntityType.AnyString + "/path%20to/this%20is%20a%20test.xyz", udi3.ToString()); }
public void Convert_Valid_Json() { var editor = CreateConverter(); var config = ConfigForMany(); var propertyType = GetPropertyType(config); var publishedElement = Mock.Of <IPublishedElement>(); var json = @" { layout: { '" + Constants.PropertyEditors.Aliases.BlockList + @"': [ { 'contentUdi': 'umb://element/1304E1DDAC87439684FE8A399231CB3D' } ] }, contentData: [ { 'contentTypeKey': '" + ContentKey1 + @"', 'udi': 'umb://element/1304E1DDAC87439684FE8A399231CB3D' } ] }"; var converted = editor.ConvertIntermediateToObject(publishedElement, propertyType, PropertyCacheLevel.None, json, false) as BlockListModel; Assert.IsNotNull(converted); Assert.AreEqual(1, converted.Count); var item0 = converted[0].Content; Assert.AreEqual(Guid.Parse("1304E1DD-AC87-4396-84FE-8A399231CB3D"), item0.Key); Assert.AreEqual("Test1", item0.ContentType.Alias); Assert.IsNull(converted[0].Settings); Assert.AreEqual(Udi.Parse("umb://element/1304E1DDAC87439684FE8A399231CB3D"), converted[0].ContentUdi); }
public Node getNodeByUDI(string nodeUDI) { var helper = new UmbracoHelper(UmbracoContext.Current); var node = new Node(helper.GetIdForUdi(Udi.Parse(nodeUDI))); return(node); }
public ActionResult SubmitApprenticeshipImage(ApprenticeshipImageModel model) { var contentService = Services.ContentService; var content = contentService.GetById(model.ApprenticeshipId); if (model.MainImage != null && ModelState.IsValid) { string extension = Path.GetExtension(model.MainImage.FileName).Replace(".", ""); if (!utilities.ValidImageFileExtension(extension)) { ModelState.AddModelError("", "Only image file types are allowed (png, jpg, jpeg, gif, webp, tiff)"); return(PartialView(GetTasksViewPath("_ApprenticeshipImage"), model)); } var mediaUdi = _mediaUploadService.CreateMediaItemFromFileUpload(model.MainImage, PAGE_IMAGES_FOLDER_ID, "Image"); content.SetValue(Apprenticeship.GetModelPropertyType(x => x.MainImage).Alias, mediaUdi); contentService.SaveAndPublish(content); string _mediaUdi = content.GetValue("mainImage") != null?content.GetValue("mainImage").ToString() : ""; if (!string.IsNullOrEmpty(_mediaUdi)) { Udi imageUdi = Udi.Parse(_mediaUdi); model.ImageUrl = Umbraco.PublishedContent(imageUdi).Url(); } ViewData["successMessage"] = string.Format(" The file <b><i>{0}</i></b> was succesfully uploaded.<br />", model.MainImage.FileName); } return(PartialView(GetTasksViewPath("_ApprenticeshipImage"), model)); }
public string ComputeReplacement(Match matchResult) { var uri = matchResult.Value; var item = _context.Content.GetById(Udi.Parse(uri)); return(item.Url().Trim("/") + ".json"); }
public dynamic GetAddressByUdi(string udi) { var umbracoHelper = new UmbracoHelper(UmbracoContext); string venueStringUdi = HttpUtility.UrlDecode(udi); Udi venueUdi = Udi.Parse(venueStringUdi); IPublishedContent venueNode = umbracoHelper.TypedContent(venueUdi); string venueAddress = venueNode.GetPropertyValue <string>("address"); return(new { value = venueAddress }); }
public void StringEntityParseTest() { var udi = Udi.Parse("umb://" + Constants.UdiEntityType.AnyString + "/test-id"); Assert.AreEqual(Constants.UdiEntityType.AnyString, udi.EntityType); Assert.IsInstanceOf <StringUdi>(udi); var stringEntityId = udi as StringUdi; Assert.IsNotNull(stringEntityId); Assert.AreEqual("test-id", stringEntityId.Id); Assert.AreEqual("umb://" + Constants.UdiEntityType.AnyString + "/test-id", udi.ToString()); }
public List <Match> GetMatches(int parentId) { List <Match> res = new List <Match>(); var matches = cs.GetDescendants(parentId); foreach (var match in matches) { if (match.ContentType.Alias == "match") { var m = new Match { Id = match.Id, Name = match.Name, MatchDate = DateTime.Parse(match.Properties["matchStart"].Value.ToString()), TeamId = cs.GetParent(cs.GetParent(match.Id).Id).Id }; // TeamId has to be defined m.ClubId = cs.GetParent(cs.GetParent(m.TeamId).Id).Id; try { string guid = match.Properties["matchOpponent"].Value.ToString(); var uid = Udi.Parse(guid); var media = Umbraco.GetIdForUdi(uid); m.OpponentId = media; } catch (NullReferenceException e) { Console.WriteLine(e.Message); } try { string guid = match.Properties["matchSponsors"].Value.ToString(); var uid = Udi.Parse(guid); var media = Umbraco.GetIdForUdi(uid); m.SponsorId = media; } catch (NullReferenceException e) { Console.WriteLine(e.Message); } res.Add(m); } } return(res); }
private static object ConvertMediaPicker(object value) { if (value != null) { var udi = Udi.Parse(value.ToString()); var media = Current.Services.MediaService.GetById(((GuidUdi)udi).Guid); if (media != null) { return(media.GetUrl("umbracoFile", null)); } } return(null); }
public void GuidUdiParseTest() { var guid = Guid.NewGuid(); var s = "umb://" + Constants.UdiEntityType.AnyGuid + "/" + guid.ToString("N"); var udi = Udi.Parse(s); Assert.AreEqual(Constants.UdiEntityType.AnyGuid, udi.EntityType); Assert.IsInstanceOf <GuidUdi>(udi); var gudi = udi as GuidUdi; Assert.IsNotNull(gudi); Assert.AreEqual(guid, gudi.Guid); Assert.AreEqual(s, udi.ToString()); }
public ActionResult ApprenticeshipImage(int apprenticeshipId) { var contentService = Services.ContentService; var content = contentService.GetById(apprenticeshipId); ApprenticeshipImageModel model = new ApprenticeshipImageModel(); string mediaUdi = content.GetValue("mainImage") != null?content.GetValue("mainImage").ToString() : ""; if (!string.IsNullOrEmpty(mediaUdi)) { Udi imageUdi = Udi.Parse(mediaUdi); model.ImageUrl = Umbraco.PublishedContent(imageUdi).Url(); } model.ApprenticeshipId = apprenticeshipId; return(PartialView(GetTasksViewPath("_ApprenticeshipImage"), model)); }
public string getDocumentByUId(string UId) { if (UId.Contains("umb://") == false) { return(UId); } var UIdArray = UId.Split(','); List <string> DocIdList = new List <string>(); foreach (var item in UIdArray) { DocIdList.Add(_umbracoHelper.TypedContent(Udi.Parse(item)).ToString()); } return(string.Join(",", DocIdList.ToArray())); }
public void Returns_Udis_From_Data_Udi_Html_Attributes() { var input = @"<p> <div> <img src='/media/12312.jpg' data-udi='umb://media/D4B18427A1544721B09AC7692F35C264' /> </div> </p><p><img src='/media/234234.jpg' data-udi=""umb://media-type/B726D735E4C446D58F703F3FBCFC97A5"" /></p>"; var umbracoContextAccessor = new TestUmbracoContextAccessor(); var imageSourceParser = new HtmlImageSourceParser(umbracoContextAccessor); var result = imageSourceParser.FindUdisFromDataAttributes(input).ToList(); Assert.AreEqual(2, result.Count); Assert.AreEqual(Udi.Parse("umb://media/D4B18427A1544721B09AC7692F35C264"), result[0]); Assert.AreEqual(Udi.Parse("umb://media-type/B726D735E4C446D58F703F3FBCFC97A5"), result[1]); }
public static Udi GetUdiPropertyValue(this Property property, string name) { if (property == null) { return(null); } string id = property.Value?.ToString(); if (id == null) { return(null); } Udi udi = Udi.Parse(id); return(udi); }
public void Returns_Udis_From_LocalLinks() { var input = @"<p> <div> <img src='/media/12312.jpg' data-udi='umb://media/D4B18427A1544721B09AC7692F35C264' /> <a href=""{locallink:umb://document/C093961595094900AAF9170DDE6AD442}"">hello</a> </div> </p><p><img src='/media/234234.jpg' data-udi=""umb://media-type/B726D735E4C446D58F703F3FBCFC97A5"" /> <a href=""{locallink:umb://document-type/2D692FCB070B4CDA92FB6883FDBFD6E2}"">hello</a> </p>"; var umbracoContextAccessor = new TestUmbracoContextAccessor(); var parser = new HtmlLocalLinkParser(umbracoContextAccessor); var result = parser.FindUdisFromLocalLinks(input).ToList(); Assert.AreEqual(2, result.Count); Assert.AreEqual(Udi.Parse("umb://document/C093961595094900AAF9170DDE6AD442"), result[0]); Assert.AreEqual(Udi.Parse("umb://document-type/2D692FCB070B4CDA92FB6883FDBFD6E2"), result[1]); }
public ActionResult HandleFormSubmit(CommentFormViewModel model) { if (!ModelState.IsValid) { return(CurrentUmbracoPage()); } //post comment Udi udi = Udi.Parse(@"umb://document/" + CurrentPage.Key.ToString());//Parse Udi for CreateContent(). var newComment = Services.ContentService.CreateContent(model.Title, udi, "commentPost"); newComment.SetValue("title", model.Title); newComment.SetValue("author", model.Author); newComment.SetValue("email", model.Email); //newComment.SetValue("comment", model.Comment); newComment.SetValue("comment", model.Comment); Services.ContentService.SaveAndPublish(newComment); TempData["success"] = true; return(RedirectToCurrentUmbracoPage()); }
public HttpResponseMessage GetById(string id, string culture = null) { var udiList = new List <Udi>(); var udi = Udi.Parse(id); udiList.Add(udi); var entity = Services.ContentService.GetByIds(udiList).FirstOrDefault(); if (entity != null) { string entityName = entity.Name; string entityUrl = "#"; if (entity.Published) { var publishedEntity = Umbraco.Content(entity.Key); if (publishedEntity != null) { entityName = publishedEntity.Name(culture); entityUrl = publishedEntity.Url(culture); } } return(Request.CreateResponse(HttpStatusCode.OK, new { id = entity.Id, udi = entity.GetUdi(), name = entityName, icon = entity.ContentType.Icon, url = entityUrl, published = entity.Published, naviHide = entity.HasProperty("umbracoNaviHide") && entity.GetValue <bool>("umbracoNaviHide"), culture = culture })); } return(null); }
/// <summary> /// Method to convert a property value to an instance of the LinkPicker class. /// </summary> /// <param name="propertyType">The current published property /// type to convert.</param> /// <param name="source">The original property data.</param> /// <param name="preview">True if in preview mode.</param> /// <returns>An instance of the LinkPicker class.</returns> public override object ConvertSourceToObject(PublishedPropertyType propertyType, object source, bool preview) { if (source == null) { return(null); } if (UmbracoContext.Current == null) { return(null); } var sourceString = source.ToString(); var umbracoHelper = new UmbracoHelper(UmbracoContext.Current); try { var linkPicker = JsonConvert.DeserializeObject <Models.LinkPicker>(sourceString); if (linkPicker.Id > 0 || !string.IsNullOrWhiteSpace(linkPicker.Udi)) { var content = linkPicker.Udi != null ? umbracoHelper.TypedContent(Udi.Parse(linkPicker.Udi)) : umbracoHelper.TypedContent(linkPicker.Id); linkPicker.Url = content?.Url ?? linkPicker.Url; } return(linkPicker); } catch (Exception ex) { LogHelper.Error <LinkPickerValueConverter>(ex.Message, ex); return(null); } }
public List <Player> GetPlayers(int parentId) { var cs = Services.ContentService; List <Player> res = new List <Player>(); var players = cs.GetDescendants(parentId); foreach (var player in players) { if (player.ContentType.Alias == "player") { var p = new Player { Id = player.Id, FirstName = player.Properties["firstName"].Value.ToString(), LastName = player.Properties["lastName"].Value.ToString(), JerseyNumber = int.Parse(player.Properties["jerseyNumber"].Value.ToString()) }; try { string guid = player.Properties["playerImage"].Value.ToString(); var udi = Udi.Parse(guid); var media = Umbraco.GetIdForUdi(udi); var content = Umbraco.Media(media); var imgPath = content.Url; p.PlayerImage = imgPath; } catch (NullReferenceException e) { Console.WriteLine(e.Message); } res.Add(p); } } return(res); }
public List <Club> GetClubs(int rootId) { List <Club> res = new List <Club>(); var clubs = cs.GetChildren(rootId); foreach (var club in clubs) { List <Team> teams = tc.GetTeams(club.Id); var c = new Club { Id = club.Id, Name = club.Properties["clubTitle"].Value.ToString(), Description = club.Properties["clubDescription"].Value.ToString(), Teams = teams }; try { string guid = club.Properties["clubLogo"].Value.ToString(); var udi = Udi.Parse(guid); var media = Umbraco.GetIdForUdi(udi); var content = Umbraco.Media(media); var imgPath = content.Url; c.ClubLogo = imgPath; } catch (NullReferenceException e) { Console.WriteLine(e.Message); } res.Add(c); } return(res); }
public void StringEncodingTest2() { // reserved = : / ? # [ ] @ ! $ & ' ( ) * + , ; = // unreserved = alpha digit - . _ ~ Assert.AreEqual("%3A%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2B%2C%3B%3D.-_~%25", Uri.EscapeDataString(":/?#[]@!$&'()+,;=.-_~%")); Assert.AreEqual(":/?#[]@!$&'()+,;=.-_~%25", Uri.EscapeUriString(":/?#[]@!$&'()+,;=.-_~%")); // we cannot have reserved chars at random places // we want to keep the / in string udis var r = string.Join("/", "path/to/View[1].cshtml".Split('/').Select(Uri.EscapeDataString)); Assert.AreEqual("path/to/View%5B1%5D.cshtml", r); Assert.IsTrue(Uri.IsWellFormedUriString("umb://partial-view-macro/" + r, UriKind.Absolute)); // with the proper fix in StringUdi this should work: var udi1 = new StringUdi("partial-view-macro", "path/to/View[1].cshtml"); Assert.AreEqual("umb://partial-view-macro/path/to/View%5B1%5D.cshtml", udi1.ToString()); var udi2 = Udi.Parse("umb://partial-view-macro/path/to/View%5B1%5D.cshtml"); Assert.AreEqual("path/to/View[1].cshtml", ((StringUdi)udi2).Id); }
private int GetIdForUdi(string udi) { return(uh.Content(Udi.Parse(udi)).Id); }
private void MemberService_Saving(IMemberService sender, SaveEventArgs <IMember> e) { var umbracoHelper = new UmbracoHelper(UmbracoContext.Current); var faceServiceClient = new FaceServiceClient(_faceApiKey, _faceApiUrl); foreach (IMember member in e.SavedEntities) { var profileImage = member.GetValue <string>("profilePicture"); if (!string.IsNullOrWhiteSpace(profileImage)) { var profileImageUdi = Udi.Parse(profileImage); var profileImageMedia = umbracoHelper.TypedMedia(profileImageUdi); string fullPath = _fs.GetFullPath(profileImageMedia.Url); /* Stap 2 -> Face API: Delete the person if exists */ if (!string.IsNullOrWhiteSpace(member.GetValue <string>("personId"))) { try { var personId = Guid.Parse(member.GetValue <string>("personId")); AsyncHelpers.RunSync(() => faceServiceClient.DeletePersonAsync(_faceApiGroup, personId)); } catch { // ignored } } /* Stap 3 -> Face API: Detect face and attributes */ using (Stream imageFileStream = _fs.OpenFile(fullPath)) { Face[] detectface = AsyncHelpers.RunSync( () => faceServiceClient.DetectAsync(imageFileStream, false, false, new[] { FaceAttributeType.Age, FaceAttributeType.Gender, FaceAttributeType.Glasses, FaceAttributeType.Makeup, FaceAttributeType.Hair, })); // Getting values and setting the properties on the member string age = detectface.First().FaceAttributes.Age.ToString(); string gender = detectface.First().FaceAttributes.Gender; string glasses = detectface.First().FaceAttributes.Glasses.ToString(); bool eyeMakeup = detectface.First().FaceAttributes.Makeup.EyeMakeup; bool lipMakeup = detectface.First().FaceAttributes.Makeup.LipMakeup; member.SetValue("Age", age); member.SetValue("Gender", gender); member.SetValue("glasses", glasses); member.SetValue("eyeMakeup", eyeMakeup); member.SetValue("lipMakeup", lipMakeup); } // ==> Stap 4 -> Create a person in the persongroup CreatePersonResult person = AsyncHelpers.RunSync(() => faceServiceClient.CreatePersonAsync(_faceApiGroup, member.Name)); member.SetValue("personId", person.PersonId.ToString()); // ==> Stap 5 -> Add face to person and make persistent using (Stream imageFileStream = _fs.OpenFile(fullPath)) { AddPersistedFaceResult result = AsyncHelpers.RunSync(() => faceServiceClient.AddPersonFaceAsync(_faceApiGroup, person.PersonId, imageFileStream)); member.SetValue("faceId", result.PersistedFaceId.ToString()); } } } // ==> Stap 6 -> Train the facegroup AsyncHelpers.RunSync(() => faceServiceClient.TrainPersonGroupAsync(_faceApiGroup)); }
public Match GetMatch(int matchId) { var match = cs.GetById(matchId); Match res = new Match { Id = match.Id, Name = match.Name, MatchDate = DateTime.Parse(match.Properties["matchStart"].Value.ToString()), TeamId = cs.GetParent(cs.GetParent(match.Id).Id).Id }; // TeamId has to be defined res.ClubId = cs.GetParent(cs.GetParent(res.TeamId).Id).Id; if (match.ContentType.Alias == "match") { try { string guid = match.Properties["matchOpponent"].Value.ToString(); var uid = Udi.Parse(guid); var media = Umbraco.GetIdForUdi(uid); res.OpponentId = media; } catch (NullReferenceException e) { Console.WriteLine(e.Message); } try { string guid = match.Properties["matchSponsors"].Value.ToString(); var uid = Udi.Parse(guid); var media = Umbraco.GetIdForUdi(uid); res.SponsorId = media; } catch (NullReferenceException e) { Console.WriteLine(e.Message); } try { if (res.SponsorId != 0) { var sponsor = cs.GetById(res.SponsorId); res.SponsorName = sponsor.Name; string guid = sponsor.Properties["logo"].Value.ToString(); var udi = Udi.Parse(guid); var media = Umbraco.GetIdForUdi(udi); var content = Umbraco.Media(media); var imgPath = content.Url; res.SponsorImagePath = mediaBaseUri + imgPath; } } catch (Exception e) { Console.WriteLine(e.Message); } try { var team = cs.GetById(res.TeamId); res.TeamName = team.Name; } catch (NullReferenceException e) { Console.WriteLine(e.Message); } try { var club = cs.GetById(res.ClubId); string guid = club.Properties["clubLogo"].Value.ToString(); var udi = Udi.Parse(guid); var media = Umbraco.GetIdForUdi(udi); var content = Umbraco.Media(media); var imgPath = content.Url; res.ClubImagePath = mediaBaseUri + imgPath; } catch (NullReferenceException e) { Console.WriteLine(e.Message); } try { var opponent = cs.GetById(res.OpponentId); res.OpponentName = opponent.Name; var opponentClub = cs.GetParent(cs.GetParent(opponent.Id).Id); string guid = opponentClub.Properties["clubLogo"].Value.ToString(); var udi = Udi.Parse(guid); var media = Umbraco.GetIdForUdi(udi); var content = Umbraco.Media(media); var imgPath = content.Url; res.OpponentClubImagePath = mediaBaseUri + imgPath; } catch (NullReferenceException e) { Console.WriteLine(e.Message); } return(res); } return(new Match()); }