summaryrefslogtreecommitdiff
path: root/Models/MyDarlingRepository.cs
blob: 07caff854c75d632a9ed7fd740be879e8221e455 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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();
		}
	}
}