using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using DMS.WPF.ViewModels.Items;
using System.Threading.Tasks;

namespace DMS.WPF.ViewModels.Dialogs;

public partial class DeviceDialogViewModel : DialogViewModelBase<DeviceItemViewModel>
{
    [ObservableProperty]
    private bool _isAddMode;
    
    [ObservableProperty]
    private DeviceItemViewModel _device;

    public DeviceDialogViewModel(DeviceItemViewModel device=null)
    {
        if (device==null)
        {
            _device = new DeviceItemViewModel();
            IsAddMode=true;
        }
        else
        {
            _device=device;
         
        }
        
    }

    [RelayCommand]
    private async Task PrimaryButton()
    {
        await Close(Device);
    }

    [RelayCommand]
    private async Task CancleButton()
    {
        await Close(null);
    }
}