Initial commit

This commit is contained in:
2026-01-15 15:22:05 +01:00
commit 0942f0b308
36 changed files with 1525 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Http;
using Oqtane.Modules;
using Oqtane.Repository;
using Oqtane.Infrastructure;
using Oqtane.Repository.Databases.Interfaces;
namespace SZUAbsolventenverein.Module.PremiumArea.Repository
{
public class PremiumAreaContext : DBContextBase, ITransientService, IMultiDatabase
{
public virtual DbSet<Models.PremiumArea> PremiumArea { get; set; }
public PremiumAreaContext(IDBContextDependencies DBContextDependencies) : base(DBContextDependencies)
{
// ContextBase handles multi-tenant database connections
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<Models.PremiumArea>().ToTable(ActiveDatabase.RewriteName("SZUAbsolventenvereinPremiumArea"));
}
}
}

View File

@@ -0,0 +1,75 @@
using Microsoft.EntityFrameworkCore;
using System.Linq;
using System.Collections.Generic;
using Oqtane.Modules;
namespace SZUAbsolventenverein.Module.PremiumArea.Repository
{
public interface IPremiumAreaRepository
{
IEnumerable<Models.PremiumArea> GetPremiumAreas(int ModuleId);
Models.PremiumArea GetPremiumArea(int PremiumAreaId);
Models.PremiumArea GetPremiumArea(int PremiumAreaId, bool tracking);
Models.PremiumArea AddPremiumArea(Models.PremiumArea PremiumArea);
Models.PremiumArea UpdatePremiumArea(Models.PremiumArea PremiumArea);
void DeletePremiumArea(int PremiumAreaId);
}
public class PremiumAreaRepository : IPremiumAreaRepository, ITransientService
{
private readonly IDbContextFactory<PremiumAreaContext> _factory;
public PremiumAreaRepository(IDbContextFactory<PremiumAreaContext> factory)
{
_factory = factory;
}
public IEnumerable<Models.PremiumArea> GetPremiumAreas(int ModuleId)
{
using var db = _factory.CreateDbContext();
return db.PremiumArea.Where(item => item.ModuleId == ModuleId).ToList();
}
public Models.PremiumArea GetPremiumArea(int PremiumAreaId)
{
return GetPremiumArea(PremiumAreaId, true);
}
public Models.PremiumArea GetPremiumArea(int PremiumAreaId, bool tracking)
{
using var db = _factory.CreateDbContext();
if (tracking)
{
return db.PremiumArea.Find(PremiumAreaId);
}
else
{
return db.PremiumArea.AsNoTracking().FirstOrDefault(item => item.PremiumAreaId == PremiumAreaId);
}
}
public Models.PremiumArea AddPremiumArea(Models.PremiumArea PremiumArea)
{
using var db = _factory.CreateDbContext();
db.PremiumArea.Add(PremiumArea);
db.SaveChanges();
return PremiumArea;
}
public Models.PremiumArea UpdatePremiumArea(Models.PremiumArea PremiumArea)
{
using var db = _factory.CreateDbContext();
db.Entry(PremiumArea).State = EntityState.Modified;
db.SaveChanges();
return PremiumArea;
}
public void DeletePremiumArea(int PremiumAreaId)
{
using var db = _factory.CreateDbContext();
Models.PremiumArea PremiumArea = db.PremiumArea.Find(PremiumAreaId);
db.PremiumArea.Remove(PremiumArea);
db.SaveChanges();
}
}
}