first edit
This commit is contained in:
56
XLIMS.SP/ViewModels/DeviceViewModel.cs
Normal file
56
XLIMS.SP/ViewModels/DeviceViewModel.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
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.SP.ViewModels
|
||||
{
|
||||
public class DeviceViewModel : ViewModelBase
|
||||
{
|
||||
#region Constructor
|
||||
public DeviceViewModel(ILimsService limsService, DivisionSet division, DeviceSet device = null)
|
||||
{
|
||||
_limsService = limsService;
|
||||
if (device != null) _device = device;
|
||||
else _device = new DeviceSet() { DivisionId = division.Id };
|
||||
}
|
||||
#endregion //Constructor
|
||||
|
||||
#region Events
|
||||
#endregion //Events
|
||||
|
||||
#region Fields
|
||||
private readonly ILimsService _limsService;
|
||||
private readonly DeviceSet _device;
|
||||
#endregion //Fields
|
||||
|
||||
#region Properties
|
||||
public string? Tip
|
||||
{
|
||||
get => _device.Tip;
|
||||
set { _device.Tip = value; OnPropertyChanged(); }
|
||||
}
|
||||
public int Id => _device.Id;
|
||||
#endregion //Properties
|
||||
|
||||
#region Methods
|
||||
private async Task SaveAsync()
|
||||
{
|
||||
if (_device.Id == 0) await _limsService.Devices.AddAsync(_device);
|
||||
else await _limsService.Devices.UpdateAsync(_device);
|
||||
}
|
||||
public async Task Remove()
|
||||
{
|
||||
await _limsService.Devices.RemoveAsync(_device);
|
||||
}
|
||||
#endregion //Methods
|
||||
|
||||
#region Commands
|
||||
public ICommand SaveCommand => new AsyncRelayCommand(SaveAsync);
|
||||
#endregion //Commands
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user