Added EF and DB to the core, crude demo in the UI

This commit is contained in:
2026-08-23 20:42:42 +03:00 Unverified
parent db368674d4
commit fb8427bd0e
20 changed files with 285 additions and 36 deletions
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using WinWARP.Core.Models.Entities;
using WinWARP.Core.Services.Interfaces;
namespace WinWARP.Core.ViewModels;
public partial class SubsSettingsViewModel(ISubscriptionDbService dbService) : ObservableObject
{
private readonly ISubscriptionDbService _dbService = dbService;
public ObservableCollection<Subscription> Subscriptions { get; } = [];
public async Task LoadSubscriptionsAsync()
{
Subscriptions.Clear();
var data = await _dbService.GetSubscriptionsAsync();
foreach (var subscription in data)
{
Subscriptions.Add(subscription);
}
}
[ObservableProperty]
[NotifyCanExecuteChangedFor(nameof(AddSubscriptionCommand))]
public partial string NewSubscriptionLink { get; set; } = string.Empty;
[RelayCommand(CanExecute = nameof(CanAddSubscription))]
public async Task AddSubscriptionAsync()
{
if (!string.IsNullOrWhiteSpace(NewSubscriptionLink))
{
var subscription = new Subscription
{
Link = NewSubscriptionLink,
Title = "New Subscription",
UpdateInterval = 60 // Default update interval
};
await _dbService.AddSubscriptionAsync(subscription);
Subscriptions.Add(subscription);
NewSubscriptionLink = string.Empty;
}
}
private bool CanAddSubscription()
{
return !string.IsNullOrWhiteSpace(NewSubscriptionLink);
}
}