Added EF and DB to the core, crude demo in the UI
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using WinWARP.Core.Data;
|
||||
using WinWARP.Core.Models.Entities;
|
||||
using WinWARP.Core.Services.Interfaces;
|
||||
|
||||
namespace WinWARP.Core.Services.Implementations;
|
||||
|
||||
public class SubscriptionDbService : ISubscriptionDbService
|
||||
{
|
||||
private IDbContextFactory<AppDbContext> _dbContextFactory;
|
||||
|
||||
public SubscriptionDbService(IDbContextFactory<AppDbContext> dbContextFactory)
|
||||
{
|
||||
_dbContextFactory = dbContextFactory;
|
||||
}
|
||||
|
||||
public async Task<List<Subscription>> GetSubscriptionsAsync()
|
||||
{
|
||||
using var dbContext = await _dbContextFactory.CreateDbContextAsync();
|
||||
return await dbContext.Subscriptions.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task AddSubscriptionAsync(Subscription subscription)
|
||||
{
|
||||
using var dbContext = await _dbContextFactory.CreateDbContextAsync();
|
||||
dbContext.Subscriptions.Add(subscription);
|
||||
await dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WinWARP.Core.Services;
|
||||
namespace WinWARP.Core.Services.Interfaces;
|
||||
|
||||
public interface ILocalizationService
|
||||
{
|
||||
+1
-1
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
namespace WinWARP.Core.Services;
|
||||
namespace WinWARP.Core.Services.Interfaces;
|
||||
|
||||
public interface INavigationService
|
||||
{
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using WinWARP.Core.Models.Entities;
|
||||
|
||||
namespace WinWARP.Core.Services.Interfaces;
|
||||
|
||||
public interface ISubscriptionDbService
|
||||
{
|
||||
public Task<List<Subscription>> GetSubscriptionsAsync();
|
||||
public Task AddSubscriptionAsync(Subscription subscription);
|
||||
}
|
||||
Reference in New Issue
Block a user