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)
            {
                case AyaType.User:
                    return new UserBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);
                case AyaType.Widget:
                    return new WidgetBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);
                case AyaType.JobOperations:
                    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.Locale:
                    return new LocaleBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);
                case AyaType.DataFilter:
                    return new DataFilterBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);
                case AyaType.FormCustom:
                    return new FormCustomBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);


                default:
                    throw new System.NotSupportedException($"AyaNova.BLL.BizObjectFactory::GetBizObject type {aytype.ToString()} is not supported");
            }

        }


        /////////////////////////////////////////////////////////////////////

    }//eoc


}//eons

