32 lines
683 B
C#
32 lines
683 B
C#
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace MyDarling.Models
|
|
{
|
|
public class MyDarlingRepository : IRepository
|
|
{
|
|
private DataContext context;
|
|
public MyDarlingRepository(IServiceProvider provider)
|
|
{
|
|
context = provider.CreateScope().ServiceProvider.GetRequiredService<DataContext>();
|
|
}
|
|
|
|
public IQueryable<UnderwearBundle> Bundles => context.UnderwearBundles.Include(b => b.Figures);
|
|
|
|
public void Add(UnderwearBundle b)
|
|
{
|
|
context.UnderwearBundles.Add(b);
|
|
context.SaveChanges();
|
|
}
|
|
|
|
public void Remove(UnderwearBundle b)
|
|
{
|
|
context.UnderwearBundles.Remove(b);
|
|
context.SaveChanges();
|
|
}
|
|
|
|
public void Save()
|
|
{
|
|
context.SaveChanges();
|
|
}
|
|
}
|
|
} |