Files
XLIMS/XLIMS.TPRZ/ViewModels/TprzViewModel.cs
Курнат Андрей f0e11d6379 first edit
2026-01-31 16:11:36 +03:00

62 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Windows.Input;
using XLIMS.CONTRACT;
using XLIMS.DATA.Models;
using XLIMS.MVVM.Base;
namespace XLIMS.TPRZ.ViewModels
{
public class TprzViewModel : ViewModelBase
{
#region Constructor
public TprzViewModel(ILimsService limsService, int idtip, Tprz tprz = null)
{
_limsService = limsService;
if (tprz != null) _tprz = tprz;
else _tprz = new Tprz() { Idtip = idtip };
}
#endregion //Constructor
#region Events
#endregion //Events
#region Fields
private readonly ILimsService _limsService;
private readonly Tprz _tprz;
private Spnmtp _currentSpnmtp;
#endregion //Fields
#region Properties
public string? Dpzn
{
get => _tprz.Dpzn;
set { _tprz.Dpzn = value; OnPropertyChanged(); }
}
public string? Hrtc
{
get => _tprz.Hrtc;
set { _tprz.Hrtc = value; OnPropertyChanged(); }
}
#endregion //Properties
#region Methods
private async Task SaveAsync()
{
if (_tprz.Id == 0) await _limsService.Tprzs.AddAsync(_tprz);
else await _limsService.Tprzs.UpdateAsync(_tprz);
}
public async Task Remove()
{
await _limsService.Tprzs.RemoveAsync(_tprz);
}
#endregion //Methods
#region Commands
public ICommand SaveCommand => new AsyncRelayCommand(SaveAsync);
#endregion //Commands
}
}