AutoCatAvalonia/AutoCat/ViewModels/HistoryViewModel.cs

35 lines
783 B
C#

using System;
using System.Threading.Tasks;
using AutoCatCore.Model;
using AutoCatCore.Services.Storage;
namespace AutoCat.ViewModels;
public class HistoryViewModel: ViewModelBase
{
#region Dependencies
private readonly IStorageService _storageService;
#endregion
public HistoryViewModel(IStorageService storageService)
{
_storageService = storageService;
}
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("");
}
}
}