first edit
This commit is contained in:
54
XLIMS.SP/ViewModels/PersonalViewModel.cs
Normal file
54
XLIMS.SP/ViewModels/PersonalViewModel.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 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user