Files
raven/server/AyaNova/biz/BizObjectFactory.cs
2020-04-13 20:24:05 +00:00

60 lines
2.1 KiB
C#

using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.JsonPatch;
using EnumsNET;
using AyaNova.Util;
using AyaNova.Api.ControllerHelpers;
using AyaNova.Biz;
using AyaNova.Models;
namespace AyaNova.Biz
{
internal static class BizObjectFactory
{
//Returns the biz object class that corresponds to the type presented
internal static BizObject GetBizObject(AyaType aytype, AyContext dbcontext, long userId = 1, AuthorizationRoles roles = AuthorizationRoles.All)
{
switch (aytype)
{
//CoreBizObject add here
case AyaType.User:
return new UserBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
case AyaType.Widget:
return new WidgetBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
case AyaType.ServerJob:
return new JobOperationsBiz(dbcontext, userId, roles);
case AyaType.AyaNova7Import:
return new ImportAyaNova7Biz(dbcontext, userId, roles);
case AyaType.TrialSeeder:
return new TrialBiz(dbcontext, userId, roles);
case AyaType.Translation:
return new TranslationBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
case AyaType.DataListView:
return new DataListViewBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
case AyaType.FormCustom:
return new FormCustomBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
default:
throw new System.NotSupportedException($"AyaNova.BLL.BizObjectFactory::GetBizObject type {aytype.ToString()} is not supported");
}
}
/////////////////////////////////////////////////////////////////////
}//eoc
}//eons