Files
raven/server/AyaNova/PickList/PickListFactory.cs
2020-03-12 23:16:19 +00:00

50 lines
1.5 KiB
C#

using System.Collections.Generic;
using System.Linq;
using AyaNova.Biz;
using AyaNova.Models;
namespace AyaNova.PickList
{
internal static class PickListFactory
{
//Instantiate list object specified from type
internal static IAyaPickList GetAyaPickList(AyaType ayaType)
{
switch (ayaType)
{
case AyaType.Widget:
return new WidgetPickList() as IAyaPickList;
}
return null;
}
//List all the PickList-able object types available
internal static List<NameIdItem> GetListOfAllPickListTypes(long TranslationId)
{
List<string> TranslationKeysToFetch = new List<string>();
List<NameIdItem> ret = new List<NameIdItem>();
var values = System.Enum.GetValues(typeof(AyaType));
foreach (AyaType t in values)
{
if (t.HasAttribute(typeof(CoreBizObjectAttribute)))
{
var name = t.ToString();
TranslationKeysToFetch.Add(name);
ret.Add(new NameIdItem() { Name = name, Id = (long)t });
}
}
var LT = TranslationBiz.GetSubsetStaticAsync(TranslationKeysToFetch, TranslationId).Result;
foreach (NameIdItem i in ret)
{
i.Name = LT[i.Name];
}
return ret;
}
}//eoc
}//eons