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

55 lines
1.5 KiB
C#

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 PersonalViewModel : ViewModelBase
{
#region Constructor
public PersonalViewModel(ILimsService limsService, PersonalSet personal = null)
{
_limsService = limsService;
if (personal != null) _personal = personal;
else _personal = new PersonalSet();
}
#endregion //Constructor
#region Events
#endregion //Events
#region Fields
private readonly ILimsService _limsService;
private readonly PersonalSet _personal;
#endregion //Fields
#region Properties
public string? Person
{
get => _personal.Person;
set { _personal.Person = value; OnPropertyChanged(); }
}
#endregion //Properties
#region Methods
private async Task SaveAsync()
{
if (_personal.Id == 0) await _limsService.Personals.AddAsync(_personal);
else await _limsService.Personals.UpdateAsync(_personal);
}
public async Task Remove()
{
await _limsService.Personals.RemoveAsync(_personal);
}
#endregion //Methods
#region Commands
public ICommand SaveCommand => new AsyncRelayCommand(SaveAsync);
#endregion //Commands
}
}