2023-02-16 07:23:48 +03:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
namespace MyDarling.Models
|
|
|
|
{
|
2023-02-16 08:28:59 +03:00
|
|
|
public class MyDarlingRepository : IRepository
|
|
|
|
{
|
|
|
|
private DataContext DbContext { get; }
|
|
|
|
public MyDarlingRepository(IServiceProvider provider)
|
|
|
|
{
|
|
|
|
DbContext = provider.CreateScope().ServiceProvider.GetRequiredService<DataContext>();
|
|
|
|
}
|
2023-02-16 07:23:48 +03:00
|
|
|
|
2023-02-16 08:28:59 +03:00
|
|
|
public IQueryable<UnderwearBundle> Bundles => DbContext.UnderwearBundles.Include(b => b.Figures);
|
2023-02-16 07:23:48 +03:00
|
|
|
|
2023-02-16 08:28:59 +03:00
|
|
|
public void Add(UnderwearBundle b)
|
|
|
|
{
|
|
|
|
DbContext.UnderwearBundles.Add(b);
|
|
|
|
DbContext.SaveChanges();
|
|
|
|
}
|
2023-02-16 07:23:48 +03:00
|
|
|
|
2023-02-16 08:28:59 +03:00
|
|
|
public void Remove(UnderwearBundle b)
|
|
|
|
{
|
|
|
|
DbContext.UnderwearBundles.Remove(b);
|
|
|
|
DbContext.SaveChanges();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Save()
|
|
|
|
{
|
|
|
|
DbContext.SaveChanges();
|
|
|
|
}
|
|
|
|
}
|
2023-02-16 07:23:48 +03:00
|
|
|
}
|