Files
oemanxTrader/OemanTrader.WPF/Commands/UpdateCurrentViewModelCommand.cs
2022-06-02 23:46:42 +02:00

49 lines
1.5 KiB
C#

using OemanTrader.FinantialModelingPrepAPI.Services;
using OemanTrader.WPF.State.Navigators;
using OemanTrader.WPF.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace OemanTrader.WPF.Commands
{
public class UpdateCurrentViewModelCommand : ICommand
{
public event EventHandler? CanExecuteChanged;
private INavigator _navigator;
public UpdateCurrentViewModelCommand(INavigator navigator)
{
_navigator = navigator;
}
public bool CanExecute(object? parameter)
{
return true;
}
public void Execute(object? parameter)
{
if (parameter is ViewType)
{
ViewType viewType = (ViewType)parameter;
switch (viewType)
{
case ViewType.Home:
// OBS OBS
_navigator.CurrentViewModel = new HomeViewModel(MajorIndexListingViewModel.LoadMajorIndexViewModel(new MajorIndexService( new FinantialModelingPrepAPI.FinancialModelingPrepHttpClientFactory("2035d4934632e1d7c38f15982e39d3aa"))));
break;
case ViewType.Portfolio:
_navigator.CurrentViewModel = new PortfolioViewModel();
break;
default:
break;
}
}
}
}
}