86 lines
3.6 KiB
C#
86 lines
3.6 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 if it will be "picked" on any other form
|
|
case AyaType.Contract:
|
|
return new ContractPickList() as IAyaPickList;
|
|
case AyaType.Customer:
|
|
return new CustomerPickList() as IAyaPickList;
|
|
case AyaType.HeadOffice:
|
|
return new HeadOfficePickList() as IAyaPickList;
|
|
case AyaType.Widget:
|
|
return new WidgetPickList() as IAyaPickList;
|
|
case AyaType.User:
|
|
return new UserPickList() as IAyaPickList;
|
|
case AyaType.Vendor:
|
|
return new VendorPickList() as IAyaPickList;
|
|
case AyaType.Part:
|
|
return new PartPickList() as IAyaPickList;
|
|
case AyaType.PartWarehouse:
|
|
return new PartWarehousePickList() as IAyaPickList;
|
|
case AyaType.PartAssembly:
|
|
return new PartAssemblyPickList() as IAyaPickList;
|
|
case AyaType.Project:
|
|
return new ProjectPickList() as IAyaPickList;
|
|
case AyaType.ServiceRate:
|
|
return new ServiceRatePickList() as IAyaPickList;
|
|
case AyaType.TaxCode:
|
|
return new TaxCodePickList() as IAyaPickList;
|
|
case AyaType.TravelRate:
|
|
return new TravelRatePickList() as IAyaPickList;
|
|
case AyaType.UnitModel:
|
|
return new UnitModelPickList() as IAyaPickList;
|
|
case AyaType.Unit:
|
|
return new UnitPickList() as IAyaPickList;
|
|
case AyaType.LoanUnit:
|
|
return new LoanUnitPickList() as IAyaPickList;
|
|
case AyaType.WorkOrderTemplate:
|
|
return new WorkOrderTemplatePickList() as IAyaPickList;
|
|
case AyaType.TaskGroup:
|
|
return new TaskGroupPickList() as IAyaPickList;
|
|
case AyaType.Report:
|
|
return new ReportPickList() as IAyaPickList;
|
|
|
|
default:
|
|
throw new System.NotImplementedException($"PICKLIST {ayaType} 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 |