Exemple #1
0
 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));
 }
Exemple #2
0
 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());
        }
Exemple #4
0
 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;
 }
Exemple #5
0
        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>();
        }
Exemple #6
0
 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;
 }
Exemple #7
0
 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());
            }
        }
Exemple #9
0
        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());
        }
Exemple #10
0
 public static SelectList CreateEnumList <T>(object selectedValue, TranslateableEnum <T> enumType) where T : struct, IConvertible
 {
     return(CreateEnumList(selectedValue, enumType.ValuesAndNames));
 }
Exemple #11
0
 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));
 }
Exemple #12
0
 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>();
 }
Exemple #13
0
 public static SelectList CreateEnumList <T>(object selectedValue, TranslateableEnum <T> enumType) where T : struct, Enum
 {
     return(CreateEnumList(selectedValue, enumType.AllFields));
 }