43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using System;
|
|
using AvaloniaApplication14_Inventory_300326.Models.Models;
|
|
using AvaloniaApplication14_Inventory_300326.Views;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
namespace AvaloniaApplication14_Inventory_300326.ViewModels;
|
|
|
|
public partial class PositionEditingWindowViewModel : ViewModelBase
|
|
{
|
|
private IServiceProvider _serviceProvider;
|
|
private bool _isEditing;
|
|
private PositionEditingWindow _currentWindow;
|
|
|
|
[ObservableProperty] private string _positionName;
|
|
|
|
[RelayCommand]
|
|
private void Cancel()
|
|
{
|
|
|
|
}
|
|
|
|
[RelayCommand]
|
|
private void Confirm()
|
|
{
|
|
|
|
}
|
|
public PositionEditingWindowViewModel(IServiceProvider serviceProvider, Position position)
|
|
{
|
|
_serviceProvider = serviceProvider;
|
|
_isEditing = !position.IsNew();
|
|
if (_isEditing)
|
|
{
|
|
PositionName = position.Name;
|
|
}
|
|
}
|
|
|
|
public void SetWindow(PositionEditingWindow window)
|
|
{
|
|
_currentWindow = window;
|
|
_currentWindow.ConfirmButton.Content = _isEditing ? "Изменить" : "Добавить";
|
|
}
|
|
} |