30 lines
619 B
C#
30 lines
619 B
C#
using Pf2eModel;
|
|
using Slugify;
|
|
|
|
namespace Pf2eDataScrapper.Importers;
|
|
|
|
public class DatabaseHelper
|
|
{
|
|
public readonly Pf2eDbContext Context = new();
|
|
|
|
public readonly SlugHelper Slugger = new();
|
|
|
|
private int _id;
|
|
|
|
public int NextEntityId => ++_id;
|
|
|
|
private DatabaseHelper()
|
|
{
|
|
_id = Context.Entities.Any() ? Context.Entities.Max(e => e.Id) : 0;
|
|
}
|
|
|
|
public string GenerateSlug(string name)
|
|
{
|
|
return Slugger.GenerateSlug(name);
|
|
}
|
|
|
|
public static readonly DatabaseHelper Instance = new();
|
|
|
|
public static readonly Pf2eDbContext DbContext = Instance.Context;
|
|
}
|