public ContentType GetContentType(ContentTypes type) { ContentType contentType = dbContext.ContentTypes.Where(ct => ct.Title == type.ToString().ToLower()) .First(); return(contentType); }
public static string GetContentTypeImage(this ContentTypes thisObject) { string imageName = "default" + thisObject.ToString().ToLowerInvariant() + "wwtthumbnail"; if (thisObject == ContentTypes.None) { imageName = "default" + ContentTypes.Generic.ToString().ToLowerInvariant() + "wwtthumbnail"; } return(imageName); }
public static Type GetAssetType(this ContentTypes contentType) { var memberName = contentType.ToString(); var memberInfo = typeof(ContentTypes).GetMember(memberName).FirstOrDefault(); if (memberInfo == null) { throw new InvalidOperationException($@"{nameof(ContentTypes)} missing expected member: {memberName}"); } var attribute = memberInfo.GetCustomAttributes(typeof(AssetTypeAttribute), true).FirstOrDefault(); if (attribute is AssetTypeAttribute assetTypeAttribute) { return(assetTypeAttribute.Type); } throw new InvalidOperationException( $@"{nameof(ContentTypes)} missing {nameof(AssetTypeAttribute)} on member: {memberName}" ); }
public static Exception ContentTypeNotSupported(ContentTypes contentType) { return new Exception(string.Format( RestfulContent.ContentTypeNotSupported, contentType.ToString())); }
private string GetFilePathFor(ContentTypes contentType, string key) { if (key.StartsWith(TEST_PREFIX)) { var keyWithoutPrefix = key.Replace(TEST_PREFIX, "").Replace('\\', '/'); // This is a hack to support paths on OSX/Unix if (keyWithoutPrefix.StartsWith('/')) { keyWithoutPrefix = keyWithoutPrefix.Substring(1); } var filePathForTestContent = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestContent", contentType.ToString(), $"{keyWithoutPrefix}.json")); return(filePathForTestContent); } // This is a hack to support paths on OSX/Unix if (key.StartsWith('/')) { key = key.Substring(1); } var filePath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, "Content", contentType.ToString(), $"{key.Replace('\\', '/')}.json")); return(filePath); }
public List <Wall> GetGroupAlbums(int groupId, ContentTypes type) { List <Wall> walls = dbContext.Walls.Include(w => w.WallType) .Where(w => w.GroupId == groupId && w.WallType.Title == type.ToString()).ToList(); walls.ForEach(w => w.Posts = GetPostsOfWall(w.Id).ToList()); return(walls); }