New server models
This commit is contained in:
@@ -2,10 +2,65 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using WinWARP.Core.Models.Entities;
|
||||
|
||||
namespace WinWARP.Core.ViewModels.Wrappers;
|
||||
|
||||
public partial class SubscriptionViewModel : ObservableObject
|
||||
public partial class SubscriptionViewModel : ObservableValidator
|
||||
{
|
||||
private readonly Subscription _subscription;
|
||||
|
||||
public SubscriptionViewModel(Subscription subscription)
|
||||
{
|
||||
_subscription = subscription;
|
||||
Link = subscription.Link;
|
||||
WebPage = subscription.WebPage;
|
||||
DefaultTitle = subscription.DefaultTitle;
|
||||
DefaultUpdateInterval = subscription.DefaultUpdateInterval;
|
||||
Title = subscription.Title;
|
||||
UpdateInterval = subscription.UpdateInterval;
|
||||
SupportURL = subscription.SupportURL;
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
public partial string Link { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial string WebPage { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial string DefaultTitle { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial int DefaultUpdateInterval { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial string Title { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial int UpdateInterval { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial string SupportURL { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
[NotifyCanExecuteChangedFor(nameof(SaveCommand))]
|
||||
public partial bool IsDirty { get; private set; }
|
||||
|
||||
[RelayCommand(CanExecute = nameof(CanSave))]
|
||||
private void Save()
|
||||
{
|
||||
ValidateAllProperties();
|
||||
|
||||
if (!HasErrors)
|
||||
{
|
||||
// Save logic here
|
||||
}
|
||||
}
|
||||
|
||||
private bool CanSave()
|
||||
{
|
||||
return IsDirty && !HasErrors;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user