From 3c83f9f4b01b5965e04739e5f8accf3235f8f699 Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Mon, 20 Feb 2023 21:53:21 +0300 Subject: Add base crud actions for bundles --- Models/IRepository.cs | 10 ---------- Models/MyDarlingRepository.cs | 32 -------------------------------- 2 files changed, 42 deletions(-) delete mode 100644 Models/IRepository.cs delete mode 100644 Models/MyDarlingRepository.cs (limited to 'Models') diff --git a/Models/IRepository.cs b/Models/IRepository.cs deleted file mode 100644 index 363f48d..0000000 --- a/Models/IRepository.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace MyDarling.Models -{ - public interface IRepository - { - public IQueryable Bundles { get; } - public void Add(UnderwearBundle b); - public void Remove(UnderwearBundle p); - public void Save(); - } -} \ No newline at end of file diff --git a/Models/MyDarlingRepository.cs b/Models/MyDarlingRepository.cs deleted file mode 100644 index 15f058c..0000000 --- a/Models/MyDarlingRepository.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.EntityFrameworkCore; - -namespace MyDarling.Models -{ - public class MyDarlingRepository : IRepository - { - private DataContext DbContext { get; } - public MyDarlingRepository(IServiceProvider provider) - { - DbContext = provider.CreateScope().ServiceProvider.GetRequiredService(); - } - - public IQueryable 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(); - } - } -} \ No newline at end of file -- cgit v1.2.3