using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Threading.Tasks; using AutoCatCore.Model; using AutoCatCore.Services.Storage; using ReactiveUI; namespace AutoCat.ViewModels; public class HistoryViewModel: ViewModelBase { #region Dependencies private readonly IStorageService _storageService; #endregion #region Properties public ICollection Vehicles { get; set; } #endregion public HistoryViewModel(IStorageService storageService) { _storageService = storageService; Vehicles = storageService.GetVehicles(); this.RaisePropertyChanged(nameof(Vehicles)); } public async Task AddVehicle(Vehicle vehicle) { try { await _storageService.AddVehicle(vehicle); } catch (Exception ex) { Console.WriteLine($"Exception: {ex.Message}"); Console.WriteLine($"Inner exception: {ex.InnerException?.Message}"); Console.WriteLine(""); } } }