first edit
This commit is contained in:
54
XLIMS.SP/ViewModels/SpnmtpViewModel.cs
Normal file
54
XLIMS.SP/ViewModels/SpnmtpViewModel.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
using XLIMS.CONTRACT;
|
||||
using XLIMS.DATA.Models;
|
||||
using XLIMS.MVVM.Base;
|
||||
|
||||
namespace XLIMS.SP.ViewModels
|
||||
{
|
||||
public class SpnmtpViewModel:ViewModelBase
|
||||
{
|
||||
#region Constructor
|
||||
public SpnmtpViewModel(ILimsService limsService, Spnmtp spnmtp = null)
|
||||
{
|
||||
_limsService = limsService;
|
||||
if (spnmtp != null) _spnmtp = spnmtp;
|
||||
else _spnmtp = new Spnmtp();
|
||||
}
|
||||
#endregion //Constructor
|
||||
|
||||
#region Events
|
||||
#endregion //Events
|
||||
|
||||
#region Fields
|
||||
private readonly ILimsService _limsService;
|
||||
private readonly Spnmtp _spnmtp;
|
||||
#endregion //Fields
|
||||
|
||||
#region Properties
|
||||
public string? Nmtp
|
||||
{
|
||||
get => _spnmtp.Nmtp;
|
||||
set { _spnmtp.Nmtp = value; OnPropertyChanged(); }
|
||||
}
|
||||
#endregion //Properties
|
||||
|
||||
#region Methods
|
||||
private async Task SaveAsync()
|
||||
{
|
||||
if (_spnmtp.Id == 0) await _limsService.Spnmtps.AddAsync(_spnmtp);
|
||||
else await _limsService.Spnmtps.UpdateAsync(_spnmtp);
|
||||
}
|
||||
public async Task Remove()
|
||||
{
|
||||
await _limsService.Spnmtps.RemoveAsync(_spnmtp);
|
||||
}
|
||||
#endregion //Methods
|
||||
|
||||
#region Commands
|
||||
public ICommand SaveCommand => new AsyncRelayCommand(SaveAsync);
|
||||
#endregion //Commands
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user