Files
raven/server/AyaNova/biz/BizObjectFactory.cs
2022-03-04 22:44:44 +00:00

169 lines
7.5 KiB
C#

using AyaNova.Util;
using AyaNova.Models;
namespace AyaNova.Biz
{
internal static class BizObjectFactory
{
//Returns the biz object class that corresponds to the type presented
//Used by SEARCH, REPORTING and objects with JOBS
internal static BizObject GetBizObject(AyaType ayaType,
AyContext ct,
long userId,
AuthorizationRoles roles,
long translationId = 0)
{
if (translationId == 0)
translationId = ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID;
switch (ayaType)
{
//CoreBizObject add here
case AyaType.ServerJob:
return new JobOperationsBiz(ct, userId, roles);
case AyaType.TrialSeeder:
return new TrialBiz(ct, userId, roles);
case AyaType.Translation:
return new TranslationBiz(ct, userId, translationId, roles);
case AyaType.DataListSavedFilter:
return new DataListSavedFilterBiz(ct, userId, translationId, roles);
case AyaType.FormCustom:
return new FormCustomBiz(ct, userId, translationId, roles);
case AyaType.FileAttachment:
return new AttachmentBiz(ct, userId, roles);
case AyaType.Customer:
return new CustomerBiz(ct, userId, translationId, roles);
case AyaType.CustomerNote:
return new CustomerNoteBiz(ct, userId, translationId, roles);
case AyaType.User:
return new UserBiz(ct, userId, translationId, roles);
case AyaType.Memo:
return new MemoBiz(ct, userId, translationId, roles);
case AyaType.Contract:
return new ContractBiz(ct, userId, translationId, roles);
case AyaType.HeadOffice:
return new HeadOfficeBiz(ct, userId, translationId, roles);
case AyaType.LoanUnit:
return new LoanUnitBiz(ct, userId, translationId, roles);
case AyaType.Part:
return new PartBiz(ct, userId, translationId, roles);
case AyaType.PartWarehouse:
return new PartWarehouseBiz(ct, userId, translationId, roles);
case AyaType.PartAssembly:
return new PartAssemblyBiz(ct, userId, translationId, roles);
case AyaType.PartInventory:
return new PartInventoryBiz(ct, userId, translationId, roles);
case AyaType.PartInventoryDataList:
return new PartInventoryDataListBiz(ct, userId, translationId, roles);
case AyaType.PartInventoryRequestDataList:
return new PartInventoryRequestDataListBiz(ct, userId, translationId, roles);
case AyaType.Project:
return new ProjectBiz(ct, userId, translationId, roles);
case AyaType.PurchaseOrder:
return new PurchaseOrderBiz(ct, userId, translationId, roles);
case AyaType.Unit:
return new UnitBiz(ct, userId, translationId, roles);
case AyaType.UnitModel:
return new UnitModelBiz(ct, userId, translationId, roles);
case AyaType.Vendor:
return new VendorBiz(ct, userId, translationId, roles);
//--- WorkOrder
case AyaType.WorkOrder:
case AyaType.WorkOrderItem:
case AyaType.WorkOrderItemExpense:
case AyaType.WorkOrderItemLabor:
case AyaType.WorkOrderItemLoan:
case AyaType.WorkOrderItemPart:
case AyaType.WorkOrderItemPartRequest:
case AyaType.WorkOrderItemScheduledUser:
case AyaType.WorkOrderItemTask:
case AyaType.WorkOrderItemTravel:
case AyaType.WorkOrderItemUnit:
case AyaType.WorkOrderItemOutsideService:
return new WorkOrderBiz(ct, userId, translationId, roles, UserType.Service);
//--- Quote
case AyaType.Quote:
case AyaType.QuoteItem:
case AyaType.QuoteItemExpense:
case AyaType.QuoteItemLabor:
case AyaType.QuoteItemLoan:
case AyaType.QuoteItemPart:
case AyaType.QuoteItemScheduledUser:
case AyaType.QuoteItemTask:
case AyaType.QuoteItemTravel:
case AyaType.QuoteItemUnit:
case AyaType.QuoteItemOutsideService:
return new QuoteBiz(ct, userId, translationId, roles, UserType.Service);
//---
//--- PM
case AyaType.PM:
case AyaType.PMItem:
case AyaType.PMItemExpense:
case AyaType.PMItemLabor:
case AyaType.PMItemLoan:
case AyaType.PMItemPart:
case AyaType.PMItemScheduledUser:
case AyaType.PMItemTask:
case AyaType.PMItemTravel:
case AyaType.PMItemUnit:
case AyaType.PMItemOutsideService:
return new PMBiz(ct, userId, translationId, roles, UserType.Service);
//---
case AyaType.WorkOrderStatus:
return new WorkOrderStatusBiz(ct, userId, translationId, roles);
case AyaType.Reminder:
return new ReminderBiz(ct, userId, translationId, roles);
case AyaType.Review:
return new ReviewBiz(ct, userId, translationId, roles);
case AyaType.ServiceRate:
return new ServiceRateBiz(ct, userId, translationId, roles);
case AyaType.TravelRate:
return new TravelRateBiz(ct, userId, translationId, roles);
case AyaType.TaxCode:
return new TaxCodeBiz(ct, userId, translationId, roles);
// case AyaType.ServiceBank:
// return new ServiceBankBiz(ct, userId, translationId, roles);
case AyaType.CustomerServiceRequest:
return new CustomerServiceRequestBiz(ct, userId, translationId, roles);
case AyaType.CustomerNotifySubscription:
return new CustomerNotifySubscriptionBiz(ct, userId, translationId, roles);
case AyaType.TaskGroup:
return new TaskGroupBiz(ct, userId, translationId, roles);
case AyaType.UnitMeterReading:
return new UnitMeterReadingBiz(ct, userId, translationId, roles);
case AyaType.Report:
return new ReportBiz(ct, userId, translationId, roles);
default:
throw new System.NotSupportedException($"AyaNova.BLL.BizObjectFactory::GetBizObject type {ayaType.ToString()} is not supported");
}
}
/////////////////////////////////////////////////////////////////////
}//eoc
}//eons