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 _bines; private IAgvBinService _agvBinService; public AgvBinManagerViewModel(IAgvBinService agvBinService) { _agvBinService = agvBinService; NavigatedTo(); } public void NavigatedTo() { Bines = new ObservableCollection((_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); } }