public RangeReader( IApiEngineService <TRelation, TUser> engineService, IModelParser modelParser, DbContext dbContext) { this.engineService = engineService; this.modelParser = modelParser; this.dbContext = dbContext; }
public PermissionHandler( string RequesterID, IModelParser modelParser, IApiEngineService <TRelation, TUser> EngineService, DbContext DbContext) { this.RequesterID = RequesterID; this.DbContext = DbContext; this.modelParser = modelParser; this.EngineService = EngineService; }
/// <summary> /// This function must be called in <see cref="IdentityDbContext<TUser> "/> class and in /// <see cref="OnModelCreating"/> function after <code>base.OnModelCreating (builder);</code> /// /// This function will try to create table per each relation which has been determined with /// TRelation enum type with "IntractionTable" postfix /// /// </summary> /// <param name="builder"> Microsoft.EntityFrameworkCore.ModelBuilder </param> /// <param name="engineService"> This can be an instance of any class which has /// implemented <seealso IApiEngineService<TRelation, TUser>> interface </param> /// <param name="TPH"> Table Per Hierarchy </param> /// <typeparam name="TRelation"> Type of relation enum </typeparam> /// <typeparam name="TUser"> Type of user class which is extended from <see cref="IdentityUser"/></typeparam> /// <returns></returns> public static void ConfigureAPIDatabase <TRelation, TUser> ( this ModelBuilder builder, IApiEngineService <TRelation, TUser> engineService, bool TPH = true) where TUser : IdentityUser { if (TPH) { builder.Ignore <RootModel> (); builder.Ignore <DescriptiveModel> (); builder.Ignore <VisualDescriptiveModel> (); builder.Ignore <ModelInteraction <TRelation> > (); } var relations = Enum.GetNames(typeof(TRelation)); foreach (var relation in relations) { var intractionType = engineService.MapRelationToType(relation); var entity = builder.Entity(intractionType); entity.HasKey(new string[] { "FirstModelId", "SecondModelId", "CreateDateTime", "IntractionType" }); entity.ToTable(relation + "IntractionTable"); typeof(DatabaseExtention) .GetMethod("ApplyValidIntractionQueryFilter") .MakeGenericMethod(intractionType) .Invoke(null, new object[] { builder }); } var appAssemblies = AppDomain.CurrentDomain.GetAssemblies().AsParallel(); var appName = AppDomain.CurrentDomain.FriendlyName; var types = appAssemblies .Where(assembly => assembly.GetName().Name.Equals(appName)) .FirstOrDefault() .GetExportedTypes() .Where(model => model.IsSubclassOf(typeof(RootModel)) && model.IsDefined(typeof(DirectAccessAllowedAttribute))) .ToList(); foreach (var type in types) { typeof(DatabaseExtention) .GetMethod("ApplyDeactivatedQueryFilter") .MakeGenericMethod(type) .Invoke(null, new object[] { builder }); } }
public NeutronGeneralAPI( DbContext dbContext, UserManager <TUser> userManager, IModelParser modelParser, IApiEngineService <TRelation, TUser> engineService) { this.UserManager = userManager; this.dbContext = dbContext; this.ModelParser = modelParser; this.EngineService = engineService; this.Utils = new APIUtils(); }