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; default: throw new System.NotImplementedException($"PICKLIST {ayaType} NOT IMPLEMENTED"); } //return null; } //List all the PickList-able object types available internal static List GetListOfAllPickListTypes(long TranslationId) { List TranslationKeysToFetch = new List(); List ret = new List(); 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