public static IHtmlContent EnumDropDownListFor <TModel, TEnum>(this IHtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TEnum> > expression, TranslateableEnum <TEnum> enumType, object htmlAttributes = null, object selectedValue = null) where TEnum : struct, Enum { return(htmlHelper.DropDownListFor(expression, CreateEnumList(selectedValue, enumType), htmlAttributes)); }
public static MvcHtmlString EnumDropDownListForDic <TModel, TEnum>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TEnum> > expression, TranslateableEnum <TEnum> enumType, IDictionary <string, object> htmlAttributes = null, object selectedValue = null) where TEnum : struct, IConvertible { return(htmlHelper.DropDownListFor(expression, CreateEnumList(selectedValue, enumType), htmlAttributes)); }
public string GenerateDescription(SongContract song, TranslateableEnum <SongType> songTypeNames) { var sb = new StringBuilder(); AddBasicDescription(sb, song, songTypeNames); return(sb.ToString()); }
public GlobalSearchBoxModel(EntryType?objectType, string searchTerm) { AllObjectTypes = new TranslateableEnum <EntryType>(() => global::Resources.EntryTypeNames.ResourceManager, new[] { EntryType.Undefined, EntryType.Artist, EntryType.Album, EntryType.Song, EntryType.Tag, EntryType.User }); ObjectType = objectType ?? EntryType.Artist; GlobalSearchTerm = searchTerm ?? string.Empty; }
public UserEdit() { var groups = EnumVal <UserGroupId> .Values.Where(g => EntryPermissionManager.CanEditGroupTo(Login.Manager, g)).ToArray(); EditableGroups = new TranslateableEnum <UserGroupId>(() => global::Resources.UserGroupNames.ResourceManager, groups); OwnedArtists = new List <ArtistForUserContract>(); Permissions = new List <PermissionFlagEntry>(); }
public GlobalSearchBoxModel(EntryType? objectType, string searchTerm) { AllObjectTypes = new TranslateableEnum<EntryType>(() => global::Resources.EntryTypeNames.ResourceManager, new[] { EntryType.Undefined, EntryType.Artist, EntryType.Album, EntryType.Song, EntryType.Tag, EntryType.User }); ObjectType = objectType ?? EntryType.Artist; GlobalSearchTerm = searchTerm ?? string.Empty; }
public static IEnumerable GetReportTypes <TEnum>(TranslateableEnum <TEnum> translations, HashSet <TEnum> notesRequired) where TEnum : struct, Enum { return(translations.Select(r => new { r.Id, r.Name, NotesRequired = notesRequired.Contains(r.Id) })); }
private void AddBasicDescription(StringBuilder sb, SongContract song, TranslateableEnum <SongType> songTypeNames) { var typeName = songTypeNames.GetName(song.SongType, CultureInfo.InvariantCulture); sb.Append(typeName); if (!string.IsNullOrEmpty(song.ArtistString)) { sb.AppendFormat(" by {0}", song.ArtistString); } if (song.PublishDate.HasValue) { sb.AppendFormat(", published {0}", song.PublishDate.Value.ToShortDateString()); } }
public string GenerateDescription(ArtistDetailsContract artist, string original, TranslateableEnum <ArtistType> artistTypeNames) { var sb = new StringBuilder(original); // Note: if original description is not empty, artist type is added to title instead of description if (string.IsNullOrEmpty(original)) { sb.AppendFormat("{0}.", artistTypeNames[artist.ArtistType]); } AddVoicebankDetails(sb, artist); return(sb.ToString()); }
public static SelectList CreateEnumList <T>(object selectedValue, TranslateableEnum <T> enumType) where T : struct, IConvertible { return(CreateEnumList(selectedValue, enumType.ValuesAndNames)); }
public static MvcHtmlString EnumDropDownList <TEnum>(this HtmlHelper htmlHelper, string name, TranslateableEnum <TEnum> enumType, object htmlAttributes = null, object selectedValue = null) where TEnum : struct, IConvertible { return(htmlHelper.DropDownList(name, CreateEnumList(selectedValue, enumType), htmlAttributes)); }
public UserEdit() { var groups = EnumVal<UserGroupId>.Values.Where(g => EntryPermissionManager.CanEditGroupTo(Login.Manager, g)).ToArray(); EditableGroups = new TranslateableEnum<UserGroupId>(() => global::Resources.UserGroupNames.ResourceManager, groups); OwnedArtists = new List<ArtistForUserContract>(); Permissions = new List<PermissionFlagEntry>(); }
public static SelectList CreateEnumList <T>(object selectedValue, TranslateableEnum <T> enumType) where T : struct, Enum { return(CreateEnumList(selectedValue, enumType.AllFields)); }