Ejemplo n.º 1
0
    public static SelectLookups ToSelectLookups <TKey, TValue>(this Dictionary <TKey, TValue> dictionary)
    {
        var lookups = new SelectLookups();

        foreach (var item in dictionary.OrderBy(x => x.Value))
        {
            lookups.Add(new Lookup(item.Key, item.Value));
        }

        return(lookups);
    }
Ejemplo n.º 2
0
    public static SelectLookups ToSelectLookups <T>(this IEnumerable <T> list) where T : Enum
    {
        var lookups = new SelectLookups();

        foreach (var item in list)
        {
            lookups.Add(new Lookup(item.ToInt(), item.DisplayName()));
        }

        return(lookups);
    }
Ejemplo n.º 3
0
    public static SelectLookups ToSelectLookups <TEntity>(this IEnumerable <TEntity> list)
        where TEntity : ILookupableEntity
    {
        var lookups = new SelectLookups();

        foreach (var item in list)
        {
            lookups.Add(new Lookup(item.Id, item.Name));
        }

        return(lookups);
    }
Ejemplo n.º 4
0
    public static SelectLookups ToSelectLookups <T, TValue>(
        this IEnumerable <Enumeration <T, TValue> > list) where T : Enumeration <T, TValue> where TValue : IComparable
    {
        var lookups = new SelectLookups();

        foreach (var item in list)
        {
            lookups.Add(new Lookup(item.Value, item.Name));
        }

        return(lookups);
    }
Ejemplo n.º 5
0
    public static SelectLookups ToSelectLookups <T>(
        this IEnumerable <T> list,
        Func <T, object> idFunc,
        Func <T, object> descriptionFunc)
    {
        var lookups = new SelectLookups();

        foreach (var item in list)
        {
            lookups.Add(new Lookup(idFunc(item), descriptionFunc(item)));
        }

        return(lookups);
    }
Ejemplo n.º 6
0
        public void Can_convert_enumeration_of_T_to_lookups()
        {
            // arrange
            // act
            var lookups = SelectLookups.FromEnum <UserTypes>();

            // assert
            lookups.ShouldCount(3);

            lookups[0].Id.ShouldBe("1");
            lookups[0].Description.ShouldBe("Administrator");

            lookups[2].Id.ShouldBe("3");
            lookups[2].Description.ShouldBe("Management");
        }