36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
|
using System.Collections.ObjectModel;
|
||
|
using System.Linq;
|
||
|
using System.Threading.Tasks;
|
||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||
|
using Seyounth.Hyosung.Data.Entities;
|
||
|
using Seyounth.Hyosung.Data.Models;
|
||
|
using Seyounth.Hyosung.Data.Services;
|
||
|
|
||
|
namespace Seyounth.Hyosung.Ava.ViewModels;
|
||
|
|
||
|
public partial class AgvBinManagerViewModel : ObservableObject
|
||
|
{
|
||
|
[ObservableProperty] private ObservableCollection<AgvBin> _bines;
|
||
|
|
||
|
private IAgvBinService _agvBinService;
|
||
|
|
||
|
public AgvBinManagerViewModel(IAgvBinService agvBinService)
|
||
|
{
|
||
|
_agvBinService = agvBinService;
|
||
|
NavigatedTo();
|
||
|
}
|
||
|
|
||
|
public void NavigatedTo()
|
||
|
{
|
||
|
Bines = new ObservableCollection<AgvBin>((_agvBinService.GetAllAsync().Result).Select(AgvBin.FromEntity));
|
||
|
foreach (var agvBin in Bines)
|
||
|
{
|
||
|
agvBin.OnDeletedChanged += AgvBinOnOnDeletedChanged;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private async Task AgvBinOnOnDeletedChanged(AgvBin arg1, bool arg2)
|
||
|
{
|
||
|
await _agvBinService.ChangeDeletedStatus(arg1.Id, arg2);
|
||
|
}
|
||
|
}
|