53 lines
1.8 KiB
C#
53 lines
1.8 KiB
C#
using System.Collections.Generic;
|
|
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)
|
|
{
|
|
//CoreBizObject add here
|
|
case AyaType.Widget:
|
|
return new WidgetPickList() as IAyaPickList;
|
|
case AyaType.User:
|
|
return new UserPickList() as IAyaPickList;
|
|
case AyaType.WorkOrderTemplate:
|
|
return new WorkOrderTemplatePickList() as IAyaPickList;
|
|
default:
|
|
throw new System.NotImplementedException("PICKLIST NOT IMPLEMENTED");
|
|
|
|
}
|
|
//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 |