0
0
MyDarling/Models/MyDarlingRepository.cs
Sergey Chebotar e4b4105ec0 Add edit page
2023-02-16 08:28:59 +03:00

32 lines
852 B
C#

using Microsoft.EntityFrameworkCore;
namespace MyDarling.Models
{
public class MyDarlingRepository : IRepository
{
private DataContext DbContext { get; }
public MyDarlingRepository(IServiceProvider provider)
{
DbContext = provider.CreateScope().ServiceProvider.GetRequiredService<DataContext>();
}
public IQueryable<UnderwearBundle> Bundles => DbContext.UnderwearBundles.Include(b => b.Figures);
public void Add(UnderwearBundle b)
{
DbContext.UnderwearBundles.Add(b);
DbContext.SaveChanges();
}
public void Remove(UnderwearBundle b)
{
DbContext.UnderwearBundles.Remove(b);
DbContext.SaveChanges();
}
public void Save()
{
DbContext.SaveChanges();
}
}
}