0
0
MyDarling/Models/MyDarlingRepository.cs
2023-02-16 07:23:48 +03:00

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();
}
}
}